3v4l.org

run code in 300+ PHP versions simultaneously
<?php class instagram_story{ protected function file_get_contents_curl($url){ $cookies = dirname(__FILE__)."/auth.txt" ; $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($curl, CURLOPT_COOKIEFILE, $cookies); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true); $answer = curl_exec($curl); curl_close($curl); return $answer; } public function getStory($username){ $url = file_get_contents("https://www.instagram.com/$username/"); $json = '/sharedData\s=\s(.*[^\"]);<.script>/ixU'; preg_match_all($json, $url, $jsondata, PREG_SET_ORDER, 0); $array = json_decode($jsondata[0][1], true); $user_id = $array['entry_data']['ProfilePage']['0']['graphql']['user']['id']; $stories = $this->file_get_contents_curl("https://www.instagram.com/graphql/query/?query_hash=de8017ee0a7c9c45ec4260733d81ea31&variables=%7B%22reel_ids%22%3A%5B%22$user_id%22%5D%2C%22tag_names%22%3A%5B%5D%2C%22location_ids%22%3A%5B%5D%2C%22highlight_reel_ids%22%3A%5B%5D%2C%22precomposed_overlay%22%3Afalse%2C%22show_story_viewer_list%22%3Atrue%2C%22story_viewer_fetch_count%22%3A50%2C%22story_viewer_cursor%22%3A%22%22%7D"); $data = json_decode($stories, true); $stories = $data['data']['reels_media']['0']['items']; $_story = []; foreach ($stories as $story) { $vid = 'video_resources'; if (!array_key_exists($vid, $story)) { $_story [] = $story['display_url']; } else { $_story [] = $story['video_resources'][0]['src']; } } foreach ($_story as $story) { $check = '/mp4/m'; preg_match_all($check, $story, $matches, PREG_SET_ORDER, 0); if (empty($matches)) { echo "<a href=$story&dl=1><img src=$story></a>"; } else { echo '<video width="320" height="240" controls>'; echo '<source src="' . $story . '" type="video/mp4">'; echo '</video>'; echo "<a href=$story&dl=1>Download</a>"; } } } } // require_once 'class.instagram.php'; if (isset($_POST['submit'])) { $story = new instagram_story(); $story->getStory($_POST['username']); } ?> <div id="center" style="text-align: center; margin-top: 300px;"> <form action="http://storiesnab.com/page/loadmedia" method="post"> <input name="username"> <input type="submit" name="submit"> </form> </div>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/0o1UN
function name:  (null)
number of ops:  14
compiled vars:  !0 = $story
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_IS                                         ~1      '_POST'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, 'submit'
          2      > JMPZ                                                     ~2, ->12
   51     3    >   NEW                                              $3      'instagram_story'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $3
   52     6        INIT_METHOD_CALL                                         !0, 'getStory'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_FUNC_ARG               global              $6      '_POST'
          9        FETCH_DIM_FUNC_ARG                               $7      $6, 'username'
         10        SEND_FUNC_ARG                                            $7
         11        DO_FCALL                                      0          
   55    12    >   ECHO                                                     '%3Cdiv+id%3D%22center%22+style%3D%22text-align%3A+center%3B+margin-top%3A+300px%3B%22%3E%0A++++%3Cform+action%3D%22http%3A%2F%2Fstoriesnab.com%2Fpage%2Floadmedia%22+method%3D%22post%22%3E%0A++++++++%3Cinput+name%3D%22username%22%3E%0A++++++++%3Cinput+type%3D%22submit%22+name%3D%22submit%22%3E%0A++++%3C%2Fform%3E%0A%3C%2Fdiv%3E'
   60    13      > RETURN                                                   1

Class instagram_story:
Function file_get_contents_curl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0o1UN
function name:  file_get_contents_curl
number of ops:  42
compiled vars:  !0 = $url, !1 = $cookies, !2 = $curl, !3 = $answer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'dirname'
          2        SEND_VAL                                                 '%2Fin%2F0o1UN'
          3        DO_ICALL                                         $4      
          4        CONCAT                                           ~5      $4, '%2Fauth.txt'
          5        ASSIGN                                                   !1, ~5
    5     6        INIT_FCALL_BY_NAME                                       'curl_init'
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
    6     9        INIT_FCALL_BY_NAME                                       'curl_setopt'
         10        SEND_VAR_EX                                              !2
         11        FETCH_CONSTANT                                   ~9      'CURLOPT_URL'
         12        SEND_VAL_EX                                              ~9
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
    7    15        INIT_FCALL_BY_NAME                                       'curl_setopt'
         16        SEND_VAR_EX                                              !2
         17        FETCH_CONSTANT                                   ~11     'CURLOPT_FOLLOWLOCATION'
         18        SEND_VAL_EX                                              ~11
         19        SEND_VAL_EX                                              1
         20        DO_FCALL                                      0          
    8    21        INIT_FCALL_BY_NAME                                       'curl_setopt'
         22        SEND_VAR_EX                                              !2
         23        FETCH_CONSTANT                                   ~13     'CURLOPT_COOKIEFILE'
         24        SEND_VAL_EX                                              ~13
         25        SEND_VAR_EX                                              !1
         26        DO_FCALL                                      0          
    9    27        INIT_FCALL_BY_NAME                                       'curl_setopt'
         28        SEND_VAR_EX                                              !2
         29        FETCH_CONSTANT                                   ~15     'CURLOPT_RETURNTRANSFER'
         30        SEND_VAL_EX                                              ~15
         31        SEND_VAL_EX                                              <true>
         32        DO_FCALL                                      0          
   10    33        INIT_FCALL_BY_NAME                                       'curl_exec'
         34        SEND_VAR_EX                                              !2
         35        DO_FCALL                                      0  $17     
         36        ASSIGN                                                   !3, $17
   11    37        INIT_FCALL_BY_NAME                                       'curl_close'
         38        SEND_VAR_EX                                              !2
         39        DO_FCALL                                      0          
   12    40      > RETURN                                                   !3
   13    41*     > RETURN                                                   null

End of function file_get_contents_curl

Function getstory:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 49, Position 2 = 64
Branch analysis from position: 49
2 jumps found. (Code = 78) Position 1 = 50, Position 2 = 64
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 58
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 64
2 jumps found. (Code = 77) Position 1 = 66, Position 2 = 94
Branch analysis from position: 66
2 jumps found. (Code = 78) Position 1 = 67, Position 2 = 94
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 84
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 94
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 94
Branch analysis from position: 64
filename:       /in/0o1UN
function name:  getStory
number of ops:  96
compiled vars:  !0 = $username, !1 = $url, !2 = $json, !3 = $jsondata, !4 = $array, !5 = $user_id, !6 = $stories, !7 = $data, !8 = $_story, !9 = $story, !10 = $vid, !11 = $check, !12 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'file_get_contents'
          2        ROPE_INIT                                     3  ~14     'https%3A%2F%2Fwww.instagram.com%2F'
          3        ROPE_ADD                                      1  ~14     ~14, !0
          4        ROPE_END                                      2  ~13     ~14, '%2F'
          5        SEND_VAL                                                 ~13
          6        DO_ICALL                                         $16     
          7        ASSIGN                                                   !1, $16
   16     8        ASSIGN                                                   !2, '%2FsharedData%5Cs%3D%5Cs%28.%2A%5B%5E%5C%22%5D%29%3B%3C.script%3E%2FixU'
   17     9        INIT_FCALL                                               'preg_match_all'
         10        SEND_VAR                                                 !2
         11        SEND_VAR                                                 !1
         12        SEND_REF                                                 !3
         13        SEND_VAL                                                 2
         14        SEND_VAL                                                 0
         15        DO_ICALL                                                 
   18    16        INIT_FCALL                                               'json_decode'
         17        FETCH_DIM_R                                      ~20     !3, 0
         18        FETCH_DIM_R                                      ~21     ~20, 1
         19        SEND_VAL                                                 ~21
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $22     
         22        ASSIGN                                                   !4, $22
   19    23        FETCH_DIM_R                                      ~24     !4, 'entry_data'
         24        FETCH_DIM_R                                      ~25     ~24, 'ProfilePage'
         25        FETCH_DIM_R                                      ~26     ~25, 0
         26        FETCH_DIM_R                                      ~27     ~26, 'graphql'
         27        FETCH_DIM_R                                      ~28     ~27, 'user'
         28        FETCH_DIM_R                                      ~29     ~28, 'id'
         29        ASSIGN                                                   !5, ~29
   20    30        INIT_METHOD_CALL                                         'file_get_contents_curl'
         31        ROPE_INIT                                     3  ~32     'https%3A%2F%2Fwww.instagram.com%2Fgraphql%2Fquery%2F%3Fquery_hash%3Dde8017ee0a7c9c45ec4260733d81ea31%26variables%3D%257B%2522reel_ids%2522%253A%255B%2522'
         32        ROPE_ADD                                      1  ~32     ~32, !5
         33        ROPE_END                                      2  ~31     ~32, '%2522%255D%252C%2522tag_names%2522%253A%255B%255D%252C%2522location_ids%2522%253A%255B%255D%252C%2522highlight_reel_ids%2522%253A%255B%255D%252C%2522precomposed_overlay%2522%253Afalse%252C%2522show_story_viewer_list%2522%253Atrue%252C%2522story_viewer_fetch_count%2522%253A50%252C%2522story_viewer_cursor%2522%253A%2522%2522%257D'
         34        SEND_VAL_EX                                              ~31
         35        DO_FCALL                                      0  $34     
         36        ASSIGN                                                   !6, $34
   21    37        INIT_FCALL                                               'json_decode'
         38        SEND_VAR                                                 !6
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $36     
         41        ASSIGN                                                   !7, $36
   22    42        FETCH_DIM_R                                      ~38     !7, 'data'
         43        FETCH_DIM_R                                      ~39     ~38, 'reels_media'
         44        FETCH_DIM_R                                      ~40     ~39, 0
         45        FETCH_DIM_R                                      ~41     ~40, 'items'
         46        ASSIGN                                                   !6, ~41
   23    47        ASSIGN                                                   !8, <array>
   24    48      > FE_RESET_R                                       $44     !6, ->64
         49    > > FE_FETCH_R                                               $44, !9, ->64
   25    50    >   ASSIGN                                                   !10, 'video_resources'
   26    51        ARRAY_KEY_EXISTS                                 ~46     !10, !9
         52        BOOL_NOT                                         ~47     ~46
         53      > JMPZ                                                     ~47, ->58
   27    54    >   FETCH_DIM_R                                      ~49     !9, 'display_url'
         55        ASSIGN_DIM                                               !8
         56        OP_DATA                                                  ~49
   26    57      > JMP                                                      ->63
   29    58    >   FETCH_DIM_R                                      ~51     !9, 'video_resources'
         59        FETCH_DIM_R                                      ~52     ~51, 0
         60        FETCH_DIM_R                                      ~53     ~52, 'src'
         61        ASSIGN_DIM                                               !8
         62        OP_DATA                                                  ~53
   24    63    > > JMP                                                      ->49
         64    >   FE_FREE                                                  $44
   32    65      > FE_RESET_R                                       $54     !8, ->94
         66    > > FE_FETCH_R                                               $54, !9, ->94
   33    67    >   ASSIGN                                                   !11, '%2Fmp4%2Fm'
   34    68        INIT_FCALL                                               'preg_match_all'
         69        SEND_VAR                                                 !11
         70        SEND_VAR                                                 !9
         71        SEND_REF                                                 !12
         72        SEND_VAL                                                 2
         73        SEND_VAL                                                 0
         74        DO_ICALL                                                 
   35    75        ISSET_ISEMPTY_CV                                         !12
         76      > JMPZ                                                     ~57, ->84
   36    77    >   ROPE_INIT                                     5  ~59     '%3Ca+href%3D'
         78        ROPE_ADD                                      1  ~59     ~59, !9
         79        ROPE_ADD                                      2  ~59     ~59, '%26dl%3D1%3E%3Cimg+src%3D'
         80        ROPE_ADD                                      3  ~59     ~59, !9
         81        ROPE_END                                      4  ~58     ~59, '%3E%3C%2Fa%3E'
         82        ECHO                                                     ~58
   35    83      > JMP                                                      ->93
   38    84    >   ECHO                                                     '%3Cvideo+width%3D%22320%22+height%3D%22240%22+controls%3E'
   39    85        CONCAT                                           ~62     '%3Csource+src%3D%22', !9
         86        CONCAT                                           ~63     ~62, '%22+type%3D%22video%2Fmp4%22%3E'
         87        ECHO                                                     ~63
   40    88        ECHO                                                     '%3C%2Fvideo%3E'
   41    89        ROPE_INIT                                     3  ~65     '%3Ca+href%3D'
         90        ROPE_ADD                                      1  ~65     ~65, !9
         91        ROPE_END                                      2  ~64     ~65, '%26dl%3D1%3EDownload%3C%2Fa%3E'
         92        ECHO                                                     ~64
   32    93    > > JMP                                                      ->66
         94    >   FE_FREE                                                  $54
   44    95      > RETURN                                                   null

End of function getstory

End of class instagram_story.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
304.34 ms | 1030 KiB | 17 Q