3v4l.org

run code in 300+ PHP versions simultaneously
<?php //INCLUDE YOUR LIST OF TWEETS AS AN ARRAY SIMILAR TO THE FOLLOWING $tweets = array( "524980794709016576", "524980794503495680", "524980792699940864" ); define('CONSUMER_KEY', "sHKRfEvXFJ3Avr3OWbkdIhkjV"); define('CONSUMER_SECRET', "HmNw6VbkFVHGObjCzYOqynz9V8NdIYlgnRcJ8K2sclLnD44dUv"); $x = base64_encode(rawurlencode(CONSUMER_KEY). ":".rawurlencode(CONSUMER_SECRET)); $url = "https://api.twitter.com/oauth2/token"; $opts = array( 'http'=>array( 'method'=>"POST", 'header'=>"Authorization:Basic $x\r\n". "Content-Type: application/x-www-form-urlencoded;charset=UTF-8.", 'content'=>"grant_type=client_credentials" ) ); $context = stream_context_create($opts); $output = file_get_contents($url,false,$context); $result = json_decode($output,true); $access_token = $result['access_token']; $query = urlencode("alibaba"); //include your query $search_url = "https://api.twitter.com/1.1/search/tweets.json?q=$query&result_type=recent&count=10"; $output = file_get_contents($search_url,false,stream_context_create(array( 'http'=>array( 'method'=>"GET", 'header'=>"Authorization:Bearer $access_token")))); $results = json_decode($output,true); //results returned as JSON $results = $results['statuses']; $c= 0; foreach ($results as $result) { $id = $result['id_str']; print $id; print "!!!"; $RTCount = $result['retweet_count']; if ($RTCount > 0) { $RTid = $result['retweeted_status']['id_str']; $tweet_url = "https://api.twitter.com/1.1/statuses/retweets/$RTid.json?count=1"; $output = file_get_contents($tweet_url,false,stream_context_create(array( 'http'=>array( 'method'=>"GET", 'header'=>"Authorization:Bearer $access_token")))); $retweets = json_decode($output,true); //results returned as JSON $last_RT = $retweets[0]['retweet_count']; } else { $last_RT = "!!!"; } //print "$tw\t$id\t$RTCount\t$last_RT\n"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 81, Position 2 = 122
Branch analysis from position: 81
2 jumps found. (Code = 78) Position 1 = 82, Position 2 = 122
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 90, Position 2 = 120
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 120
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 122
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 122
filename:       /in/i0fkM
function name:  (null)
number of ops:  124
compiled vars:  !0 = $tweets, !1 = $x, !2 = $url, !3 = $opts, !4 = $context, !5 = $output, !6 = $result, !7 = $access_token, !8 = $query, !9 = $search_url, !10 = $results, !11 = $c, !12 = $id, !13 = $RTCount, !14 = $RTid, !15 = $tweet_url, !16 = $retweets, !17 = $last_RT
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'CONSUMER_KEY'
          3        SEND_VAL                                                 'sHKRfEvXFJ3Avr3OWbkdIhkjV'
          4        DO_ICALL                                                 
   11     5        INIT_FCALL                                               'define'
          6        SEND_VAL                                                 'CONSUMER_SECRET'
          7        SEND_VAL                                                 'HmNw6VbkFVHGObjCzYOqynz9V8NdIYlgnRcJ8K2sclLnD44dUv'
          8        DO_ICALL                                                 
   13     9        INIT_FCALL                                               'base64_encode'
         10        INIT_FCALL                                               'rawurlencode'
         11        FETCH_CONSTANT                                   ~21     'CONSUMER_KEY'
         12        SEND_VAL                                                 ~21
         13        DO_ICALL                                         $22     
   14    14        CONCAT                                           ~23     $22, '%3A'
         15        INIT_FCALL                                               'rawurlencode'
         16        FETCH_CONSTANT                                   ~24     'CONSUMER_SECRET'
         17        SEND_VAL                                                 ~24
         18        DO_ICALL                                         $25     
         19        CONCAT                                           ~26     ~23, $25
         20        SEND_VAL                                                 ~26
         21        DO_ICALL                                         $27     
   13    22        ASSIGN                                                   !1, $27
   15    23        ASSIGN                                                   !2, 'https%3A%2F%2Fapi.twitter.com%2Foauth2%2Ftoken'
   18    24        INIT_ARRAY                                       ~30     'POST', 'method'
   19    25        ROPE_INIT                                     3  ~32     'Authorization%3ABasic+'
         26        ROPE_ADD                                      1  ~32     ~32, !1
         27        ROPE_END                                      2  ~31     ~32, '%0D%0A'
   20    28        CONCAT                                           ~34     ~31, 'Content-Type%3A+application%2Fx-www-form-urlencoded%3Bcharset%3DUTF-8.'
         29        ADD_ARRAY_ELEMENT                                ~30     ~34, 'header'
   21    30        ADD_ARRAY_ELEMENT                                ~30     'grant_type%3Dclient_credentials', 'content'
         31        INIT_ARRAY                                       ~35     ~30, 'http'
   16    32        ASSIGN                                                   !3, ~35
   24    33        INIT_FCALL                                               'stream_context_create'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                         $37     
         36        ASSIGN                                                   !4, $37
   25    37        INIT_FCALL                                               'file_get_contents'
         38        SEND_VAR                                                 !2
         39        SEND_VAL                                                 <false>
         40        SEND_VAR                                                 !4
         41        DO_ICALL                                         $39     
         42        ASSIGN                                                   !5, $39
   26    43        INIT_FCALL                                               'json_decode'
         44        SEND_VAR                                                 !5
         45        SEND_VAL                                                 <true>
         46        DO_ICALL                                         $41     
         47        ASSIGN                                                   !6, $41
   27    48        FETCH_DIM_R                                      ~43     !6, 'access_token'
         49        ASSIGN                                                   !7, ~43
   29    50        INIT_FCALL                                               'urlencode'
         51        SEND_VAL                                                 'alibaba'
         52        DO_ICALL                                         $45     
         53        ASSIGN                                                   !8, $45
   31    54        ROPE_INIT                                     3  ~48     'https%3A%2F%2Fapi.twitter.com%2F1.1%2Fsearch%2Ftweets.json%3Fq%3D'
         55        ROPE_ADD                                      1  ~48     ~48, !8
         56        ROPE_END                                      2  ~47     ~48, '%26result_type%3Drecent%26count%3D10'
         57        ASSIGN                                                   !9, ~47
   32    58        INIT_FCALL                                               'file_get_contents'
         59        SEND_VAR                                                 !9
         60        SEND_VAL                                                 <false>
         61        INIT_FCALL                                               'stream_context_create'
   34    62        INIT_ARRAY                                       ~51     'GET', 'method'
   35    63        NOP                                                      
         64        FAST_CONCAT                                      ~52     'Authorization%3ABearer+', !7
         65        ADD_ARRAY_ELEMENT                                ~51     ~52, 'header'
         66        INIT_ARRAY                                       ~53     ~51, 'http'
         67        SEND_VAL                                                 ~53
         68        DO_ICALL                                         $54     
         69        SEND_VAR                                                 $54
         70        DO_ICALL                                         $55     
   32    71        ASSIGN                                                   !5, $55
   36    72        INIT_FCALL                                               'json_decode'
         73        SEND_VAR                                                 !5
         74        SEND_VAL                                                 <true>
         75        DO_ICALL                                         $57     
         76        ASSIGN                                                   !10, $57
   37    77        FETCH_DIM_R                                      ~59     !10, 'statuses'
         78        ASSIGN                                                   !10, ~59
   38    79        ASSIGN                                                   !11, 0
   39    80      > FE_RESET_R                                       $62     !10, ->122
         81    > > FE_FETCH_R                                               $62, !6, ->122
   40    82    >   FETCH_DIM_R                                      ~63     !6, 'id_str'
         83        ASSIGN                                                   !12, ~63
   41    84        ECHO                                                     !12
   42    85        ECHO                                                     '%21%21%21'
   43    86        FETCH_DIM_R                                      ~65     !6, 'retweet_count'
         87        ASSIGN                                                   !13, ~65
   44    88        IS_SMALLER                                               0, !13
         89      > JMPZ                                                     ~67, ->120
   45    90    >   FETCH_DIM_R                                      ~68     !6, 'retweeted_status'
         91        FETCH_DIM_R                                      ~69     ~68, 'id_str'
         92        ASSIGN                                                   !14, ~69
   46    93        ROPE_INIT                                     3  ~72     'https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fretweets%2F'
         94        ROPE_ADD                                      1  ~72     ~72, !14
         95        ROPE_END                                      2  ~71     ~72, '.json%3Fcount%3D1'
         96        ASSIGN                                                   !15, ~71
   47    97        INIT_FCALL                                               'file_get_contents'
         98        SEND_VAR                                                 !15
         99        SEND_VAL                                                 <false>
        100        INIT_FCALL                                               'stream_context_create'
   49   101        INIT_ARRAY                                       ~75     'GET', 'method'
   50   102        NOP                                                      
        103        FAST_CONCAT                                      ~76     'Authorization%3ABearer+', !7
        104        ADD_ARRAY_ELEMENT                                ~75     ~76, 'header'
        105        INIT_ARRAY                                       ~77     ~75, 'http'
        106        SEND_VAL                                                 ~77
        107        DO_ICALL                                         $78     
        108        SEND_VAR                                                 $78
        109        DO_ICALL                                         $79     
   47   110        ASSIGN                                                   !5, $79
   51   111        INIT_FCALL                                               'json_decode'
        112        SEND_VAR                                                 !5
        113        SEND_VAL                                                 <true>
        114        DO_ICALL                                         $81     
        115        ASSIGN                                                   !16, $81
   52   116        FETCH_DIM_R                                      ~83     !16, 0
        117        FETCH_DIM_R                                      ~84     ~83, 'retweet_count'
        118        ASSIGN                                                   !17, ~84
        119      > JMP                                                      ->121
   55   120    >   ASSIGN                                                   !17, '%21%21%21'
   39   121    > > JMP                                                      ->81
        122    >   FE_FREE                                                  $62
   59   123      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.5 ms | 1409 KiB | 27 Q