3v4l.org

run code in 300+ PHP versions simultaneously
<?php $apiKey = 'AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg'; $channelId = 'UC226a2gZas0iS2KUtrF7oFw'; $maxResults = 50; $results = fetchLists($apiKey, $channelId, $maxResults); function fetchLists($apiKey, $channelId, $maxResults, $listsNextPage = null, $playlists = array()) { $ytApiUrl = 'https://www.googleapis.com/youtube/v3/playlists?maxResults=' . $maxResults . '&part=snippet&channelId=' . $channelId . '&key=' . $apiKey ; if($listsNextPage !== null){ $ytApiUrl .= '&pageToken=' . $listsNextPage; } $jsonLists = json_decode(file_get_contents($ytApiUrl)); $listsPageToken = (isset($jsonLists->nextPageToken)) ? $jsonLists->nextPageToken : null ; foreach ($jsonLists->items as $item) { $plId = $item->id; $list = array( "id" => $plId, "title" => $item->snippet->title, "published" => $item->snippet->publishedAt, "url" => 'https://www.youtube.com/playlist?list=' . $plId, "thumbnail" => $item->snippet->thumbnails->default->url, "videos" => [] ); fetchVideos($list, $playlists, $maxResults, $plId, $apiKey); } if($listsPageToken !== null){ return fetchLists($apiKey, $channelId, $maxResults, $listsPageToken, $playlists); } return $playlists; } function fetchVideos(&$list, &$playlists, &$maxResults, &$plId, &$apiKey, $vidsNextPage = null) { $plApiUrl = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults='. $maxResults .'&playlistId=' . $plId . '&key=' . $apiKey; if($vidsNextPage !== null){ $plApiUrl .= '&pageToken=' . $vidsNextPage; } $jsonPlVideos = json_decode(file_get_contents($plApiUrl)); $videosPageToken = (isset($jsonPlVideos->nextPageToken)) ? $jsonPlVideos->nextPageToken : null ; foreach ($jsonPlVideos->items as $vid) { $video = array( "title" => $vid->snippet->title, "url" => 'https://www.youtube.com/watch?v=' . $vid->snippet->resourceId->videoId, "published" => $vid->snippet->publishedAt, "thumbnail" => $vid->snippet->thumbnails->default->url ); $list['videos'][] = $video; } $playlists[] = $list; if($videosPageToken !== null){ return fetchVideos($list, $playlists, $maxResults, $plId, $apiKey, $videosPageToken); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qe40e
function name:  (null)
number of ops:  10
compiled vars:  !0 = $apiKey, !1 = $channelId, !2 = $maxResults, !3 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'AIzaSyC7udxUIPhN213ilX9Reyc_ZzXN5_id5eg'
    3     1        ASSIGN                                                   !1, 'UC226a2gZas0iS2KUtrF7oFw'
    4     2        ASSIGN                                                   !2, 50
    5     3        INIT_FCALL_BY_NAME                                       'fetchLists'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !3, $7
   53     9      > RETURN                                                   1

Function fetchlists:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 58
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 58
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 69
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 58
Branch analysis from position: 31
Branch analysis from position: 58
Branch analysis from position: 15
filename:       /in/qe40e
function name:  fetchLists
number of ops:  71
compiled vars:  !0 = $apiKey, !1 = $channelId, !2 = $maxResults, !3 = $listsNextPage, !4 = $playlists, !5 = $ytApiUrl, !6 = $jsonLists, !7 = $listsPageToken, !8 = $item, !9 = $plId, !10 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      null
          4        RECV_INIT                                        !4      <array>
   10     5        CONCAT                                           ~11     'https%3A%2F%2Fwww.googleapis.com%2Fyoutube%2Fv3%2Fplaylists%3FmaxResults%3D', !2
          6        CONCAT                                           ~12     ~11, '%26part%3Dsnippet%26channelId%3D'
          7        CONCAT                                           ~13     ~12, !1
          8        CONCAT                                           ~14     ~13, '%26key%3D'
          9        CONCAT                                           ~15     ~14, !0
         10        ASSIGN                                                   !5, ~15
   11    11        TYPE_CHECK                                  1020          !3
         12      > JMPZ                                                     ~17, ->15
   12    13    >   CONCAT                                           ~18     '%26pageToken%3D', !3
         14        ASSIGN_OP                                     8          !5, ~18
   14    15    >   INIT_FCALL                                               'json_decode'
         16        INIT_FCALL                                               'file_get_contents'
         17        SEND_VAR                                                 !5
         18        DO_ICALL                                         $20     
         19        SEND_VAR                                                 $20
         20        DO_ICALL                                         $21     
         21        ASSIGN                                                   !6, $21
   15    22        ISSET_ISEMPTY_PROP_OBJ                                   !6, 'nextPageToken'
         23      > JMPZ                                                     ~23, ->27
         24    >   FETCH_OBJ_R                                      ~24     !6, 'nextPageToken'
         25        QM_ASSIGN                                        ~25     ~24
         26      > JMP                                                      ->28
         27    >   QM_ASSIGN                                        ~25     null
         28    >   ASSIGN                                                   !7, ~25
   16    29        FETCH_OBJ_R                                      ~27     !6, 'items'
         30      > FE_RESET_R                                       $28     ~27, ->58
         31    > > FE_FETCH_R                                               $28, !8, ->58
   17    32    >   FETCH_OBJ_R                                      ~29     !8, 'id'
         33        ASSIGN                                                   !9, ~29
   19    34        INIT_ARRAY                                       ~31     !9, 'id'
   20    35        FETCH_OBJ_R                                      ~32     !8, 'snippet'
         36        FETCH_OBJ_R                                      ~33     ~32, 'title'
         37        ADD_ARRAY_ELEMENT                                ~31     ~33, 'title'
   21    38        FETCH_OBJ_R                                      ~34     !8, 'snippet'
         39        FETCH_OBJ_R                                      ~35     ~34, 'publishedAt'
         40        ADD_ARRAY_ELEMENT                                ~31     ~35, 'published'
   22    41        CONCAT                                           ~36     'https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3D', !9
         42        ADD_ARRAY_ELEMENT                                ~31     ~36, 'url'
   23    43        FETCH_OBJ_R                                      ~37     !8, 'snippet'
         44        FETCH_OBJ_R                                      ~38     ~37, 'thumbnails'
         45        FETCH_OBJ_R                                      ~39     ~38, 'default'
         46        FETCH_OBJ_R                                      ~40     ~39, 'url'
         47        ADD_ARRAY_ELEMENT                                ~31     ~40, 'thumbnail'
   19    48        ADD_ARRAY_ELEMENT                                ~31     <array>, 'videos'
   18    49        ASSIGN                                                   !10, ~31
   26    50        INIT_FCALL_BY_NAME                                       'fetchVideos'
         51        SEND_VAR_EX                                              !10
         52        SEND_VAR_EX                                              !4
         53        SEND_VAR_EX                                              !2
         54        SEND_VAR_EX                                              !9
         55        SEND_VAR_EX                                              !0
         56        DO_FCALL                                      0          
   16    57      > JMP                                                      ->31
         58    >   FE_FREE                                                  $28
   28    59        TYPE_CHECK                                  1020          !7
         60      > JMPZ                                                     ~43, ->69
   29    61    >   INIT_FCALL_BY_NAME                                       'fetchLists'
         62        SEND_VAR_EX                                              !0
         63        SEND_VAR_EX                                              !1
         64        SEND_VAR_EX                                              !2
         65        SEND_VAR_EX                                              !7
         66        SEND_VAR_EX                                              !4
         67        DO_FCALL                                      0  $44     
         68      > RETURN                                                   $44
   31    69    > > RETURN                                                   !4
   32    70*     > RETURN                                                   null

End of function fetchlists

Function fetchvideos:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 54
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 54
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 68
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 54
Branch analysis from position: 32
Branch analysis from position: 54
Branch analysis from position: 16
filename:       /in/qe40e
function name:  fetchVideos
number of ops:  69
compiled vars:  !0 = $list, !1 = $playlists, !2 = $maxResults, !3 = $plId, !4 = $apiKey, !5 = $vidsNextPage, !6 = $plApiUrl, !7 = $jsonPlVideos, !8 = $videosPageToken, !9 = $vid, !10 = $video
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV_INIT                                        !5      null
   34     6        CONCAT                                           ~11     'https%3A%2F%2Fwww.googleapis.com%2Fyoutube%2Fv3%2FplaylistItems%3Fpart%3Dsnippet%26maxResults%3D', !2
          7        CONCAT                                           ~12     ~11, '%26playlistId%3D'
          8        CONCAT                                           ~13     ~12, !3
          9        CONCAT                                           ~14     ~13, '%26key%3D'
         10        CONCAT                                           ~15     ~14, !4
         11        ASSIGN                                                   !6, ~15
   35    12        TYPE_CHECK                                  1020          !5
         13      > JMPZ                                                     ~17, ->16
   36    14    >   CONCAT                                           ~18     '%26pageToken%3D', !5
         15        ASSIGN_OP                                     8          !6, ~18
   38    16    >   INIT_FCALL                                               'json_decode'
         17        INIT_FCALL                                               'file_get_contents'
         18        SEND_VAR                                                 !6
         19        DO_ICALL                                         $20     
         20        SEND_VAR                                                 $20
         21        DO_ICALL                                         $21     
         22        ASSIGN                                                   !7, $21
   39    23        ISSET_ISEMPTY_PROP_OBJ                                   !7, 'nextPageToken'
         24      > JMPZ                                                     ~23, ->28
         25    >   FETCH_OBJ_R                                      ~24     !7, 'nextPageToken'
         26        QM_ASSIGN                                        ~25     ~24
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~25     null
         29    >   ASSIGN                                                   !8, ~25
   40    30        FETCH_OBJ_R                                      ~27     !7, 'items'
         31      > FE_RESET_R                                       $28     ~27, ->54
         32    > > FE_FETCH_R                                               $28, !9, ->54
   42    33    >   FETCH_OBJ_R                                      ~29     !9, 'snippet'
         34        FETCH_OBJ_R                                      ~30     ~29, 'title'
         35        INIT_ARRAY                                       ~31     ~30, 'title'
   43    36        FETCH_OBJ_R                                      ~32     !9, 'snippet'
         37        FETCH_OBJ_R                                      ~33     ~32, 'resourceId'
         38        FETCH_OBJ_R                                      ~34     ~33, 'videoId'
         39        CONCAT                                           ~35     'https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D', ~34
         40        ADD_ARRAY_ELEMENT                                ~31     ~35, 'url'
   44    41        FETCH_OBJ_R                                      ~36     !9, 'snippet'
         42        FETCH_OBJ_R                                      ~37     ~36, 'publishedAt'
         43        ADD_ARRAY_ELEMENT                                ~31     ~37, 'published'
   45    44        FETCH_OBJ_R                                      ~38     !9, 'snippet'
         45        FETCH_OBJ_R                                      ~39     ~38, 'thumbnails'
         46        FETCH_OBJ_R                                      ~40     ~39, 'default'
         47        FETCH_OBJ_R                                      ~41     ~40, 'url'
         48        ADD_ARRAY_ELEMENT                                ~31     ~41, 'thumbnail'
   41    49        ASSIGN                                                   !10, ~31
   47    50        FETCH_DIM_W                                      $43     !0, 'videos'
         51        ASSIGN_DIM                                               $43
         52        OP_DATA                                                  !10
   40    53      > JMP                                                      ->32
         54    >   FE_FREE                                                  $28
   49    55        ASSIGN_DIM                                               !1
         56        OP_DATA                                                  !0
   50    57        TYPE_CHECK                                  1020          !8
         58      > JMPZ                                                     ~46, ->68
   51    59    >   INIT_FCALL_BY_NAME                                       'fetchVideos'
         60        SEND_VAR_EX                                              !0
         61        SEND_VAR_EX                                              !1
         62        SEND_VAR_EX                                              !2
         63        SEND_VAR_EX                                              !3
         64        SEND_VAR_EX                                              !4
         65        SEND_VAR_EX                                              !8
         66        DO_FCALL                                      0  $47     
         67      > RETURN                                                   $47
   53    68    > > RETURN                                                   null

End of function fetchvideos

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.62 ms | 1412 KiB | 17 Q