3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fetch_fb_fans($fanpage_name, $no_of_retries = 10, $pause = 500000 /* 500ms */){ $ret = array(); // get page info from graph $fanpage_data = json_decode(file_get_contents('http://facebook.com/' . $fanpage_name), true); if(empty($fanpage_data['id'])){ // invalid fanpage name return $ret; } $matches = array(); $url = 'http://www.facebook.com/plugins/fan.php?connections=100&id=' . $fanpage_data['id']; $context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'))); for($a = 0; $a < $no_of_retries; $a++){ $like_html = file_get_contents($url, false, $context); preg_match_all('{href="https?://www\.facebook\.com/([a-zA-Z0-9._-]+)" data-jsid="anchor" target="_blank"}', $like_html, $matches); if(empty($matches[1])){ // failed to fetch any fans - convert returning array, cause it might be not empty return array_keys($ret); }else{ // merge profiles as array keys so they will stay unique $ret = array_merge($ret, array_flip($matches[1])); } // don't get banned as flooder usleep($pause); } return array_keys($ret); } print_r(fetch_fb_fans('ivcrn', 2, 400000)); // prints 73 unique fan names as array
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oE7EI
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'fetch_fb_fans'
          2        SEND_VAL                                                 'ivcrn'
          3        SEND_VAL                                                 2
          4        SEND_VAL                                                 400000
          5        DO_FCALL                                      0  $0      
          6        SEND_VAR                                                 $0
          7        DO_ICALL                                                 
   31     8      > RETURN                                                   1

Function fetch_fb_fans:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 26
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 26
Branch analysis from position: 59
Branch analysis from position: 26
filename:       /in/oE7EI
function name:  fetch_fb_fans
number of ops:  64
compiled vars:  !0 = $fanpage_name, !1 = $no_of_retries, !2 = $pause, !3 = $ret, !4 = $fanpage_data, !5 = $matches, !6 = $url, !7 = $context, !8 = $a, !9 = $like_html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      10
          2        RECV_INIT                                        !2      500000
    4     3        ASSIGN                                                   !3, <array>
    6     4        INIT_FCALL                                               'json_decode'
          5        INIT_FCALL                                               'file_get_contents'
          6        CONCAT                                           ~11     'http%3A%2F%2Ffacebook.com%2F', !0
          7        SEND_VAL                                                 ~11
          8        DO_ICALL                                         $12     
          9        SEND_VAR                                                 $12
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !4, $13
    7    13        ISSET_ISEMPTY_DIM_OBJ                         1          !4, 'id'
         14      > JMPZ                                                     ~15, ->16
    9    15    > > RETURN                                                   !3
   11    16    >   ASSIGN                                                   !5, <array>
   12    17        FETCH_DIM_R                                      ~17     !4, 'id'
         18        CONCAT                                           ~18     'http%3A%2F%2Fwww.facebook.com%2Fplugins%2Ffan.php%3Fconnections%3D100%26id%3D', ~17
         19        ASSIGN                                                   !6, ~18
   13    20        INIT_FCALL                                               'stream_context_create'
         21        SEND_VAL                                                 <array>
         22        DO_ICALL                                         $20     
         23        ASSIGN                                                   !7, $20
   14    24        ASSIGN                                                   !8, 0
         25      > JMP                                                      ->57
   15    26    >   INIT_FCALL                                               'file_get_contents'
         27        SEND_VAR                                                 !6
         28        SEND_VAL                                                 <false>
         29        SEND_VAR                                                 !7
         30        DO_ICALL                                         $23     
         31        ASSIGN                                                   !9, $23
   16    32        INIT_FCALL                                               'preg_match_all'
         33        SEND_VAL                                                 '%7Bhref%3D%22https%3F%3A%2F%2Fwww%5C.facebook%5C.com%2F%28%5Ba-zA-Z0-9._-%5D%2B%29%22+data-jsid%3D%22anchor%22+target%3D%22_blank%22%7D'
         34        SEND_VAR                                                 !9
         35        SEND_REF                                                 !5
         36        DO_ICALL                                                 
   17    37        ISSET_ISEMPTY_DIM_OBJ                         1          !5, 1
         38      > JMPZ                                                     ~26, ->44
   19    39    >   INIT_FCALL                                               'array_keys'
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                         $27     
         42      > RETURN                                                   $27
         43*       JMP                                                      ->53
   22    44    >   INIT_FCALL                                               'array_merge'
         45        SEND_VAR                                                 !3
         46        INIT_FCALL                                               'array_flip'
         47        FETCH_DIM_R                                      ~28     !5, 1
         48        SEND_VAL                                                 ~28
         49        DO_ICALL                                         $29     
         50        SEND_VAR                                                 $29
         51        DO_ICALL                                         $30     
         52        ASSIGN                                                   !3, $30
   25    53        INIT_FCALL                                               'usleep'
         54        SEND_VAR                                                 !2
         55        DO_ICALL                                                 
   14    56        PRE_INC                                                  !8
         57    >   IS_SMALLER                                               !8, !1
         58      > JMPNZ                                                    ~34, ->26
   27    59    >   INIT_FCALL                                               'array_keys'
         60        SEND_VAR                                                 !3
         61        DO_ICALL                                         $35     
         62      > RETURN                                                   $35
   28    63*     > RETURN                                                   null

End of function fetch_fb_fans

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.49 ms | 1403 KiB | 32 Q