3v4l.org

run code in 300+ PHP versions simultaneously
<?php $client_id = "239"; $client_secret = "dbd8a92f126ed1a874218f17329f9432688769b2"; $access_token = "0cd76192710efdd76818141513659835b61a188e"; $redirect_uri = "http://localhost/"; $response_type = "code"; $scope = ""; $approval_prompt = ""; function authorizeUrl($clientId, $response_type, $redirect_uri, $scope, $approval_prompt){ $authorizeUrl = "https://www.strava.com/oauth/authorize?client_id=$clientId&response_type=$response_type&redirect_uri=$redirect_uri&scope=$scope&approval_prompt=$approval_prompt"; return $authorizeUrl; } function parseJason ($response){ return json_decode($response); } function tokenRequest($clientId, $clientSecret, $code){ $oauthFields = array( client_id => $clientId, "client_secret" => $clientSecret, "code" => $code); var_dump($oauthFields); echo "<br>"; echo "<br>" . $oauthFields . "<br>"; print_r($oauthFields); $oauthFieldsObject = (object) $oauthFields; echo "<br>"; var_dump($oauthFieldsObject); echo "<br>"; print_r($oauthFieldsObject); echo "<br>"; $parameters = '&' . http_build_query($oauthFields); var_dump($parameters); echo "<br>". $parameters; echo "<br>"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.strava.com/oauth/token?"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); var_dump($ch); $urlResponse = curl_exec($ch); echo "<br>"; var_dump($urlResponse); $http_response = curl_getinfo($ch, CURLINFO_HTTP_CODE); $http_decoded = json_decode($http_response); echo "<br>" . $http_decoded; curl_close($ch); return json_decode($urlResponse); } echo $client_secret; echo "<br>"; $loginUrl = authorizeUrl($client_id,$response_type,$redirect_uri, $scope, $approval_prompt); echo "<a href='$loginUrl'>Click here<a>". "<br>" ; echo $loginUrl ."<br>"; echo 'https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force'."<br>"; $codeUrl = null; if (isset($_GET['code'])){ $codeUrl = $_GET['code']; } else { echo "<a href='$loginUrl'>Click here<a>". "<br>" ; } echo $codeUrl; $buildOauthTokenExchange = "https://wwww.strava.com/oauth/token"; echo "<br>"; $token = tokenRequest($client_id, $client_secret, $codeUrl); echo "<br>"; var_dump($token); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/81Yi3
function name:  (null)
number of ops:  52
compiled vars:  !0 = $client_id, !1 = $client_secret, !2 = $access_token, !3 = $redirect_uri, !4 = $response_type, !5 = $scope, !6 = $approval_prompt, !7 = $loginUrl, !8 = $codeUrl, !9 = $buildOauthTokenExchange, !10 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '239'
    4     1        ASSIGN                                                   !1, 'dbd8a92f126ed1a874218f17329f9432688769b2'
    5     2        ASSIGN                                                   !2, '0cd76192710efdd76818141513659835b61a188e'
    6     3        ASSIGN                                                   !3, 'http%3A%2F%2Flocalhost%2F'
    7     4        ASSIGN                                                   !4, 'code'
    8     5        ASSIGN                                                   !5, ''
    9     6        ASSIGN                                                   !6, ''
   61     7        ECHO                                                     !1
   62     8        ECHO                                                     '%3Cbr%3E'
   63     9        INIT_FCALL                                               'authorizeurl'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !4
         12        SEND_VAR                                                 !3
         13        SEND_VAR                                                 !5
         14        SEND_VAR                                                 !6
         15        DO_FCALL                                      0  $18     
         16        ASSIGN                                                   !7, $18
   64    17        ROPE_INIT                                     3  ~21     '%3Ca+href%3D%27'
         18        ROPE_ADD                                      1  ~21     ~21, !7
         19        ROPE_END                                      2  ~20     ~21, '%27%3EClick+here%3Ca%3E'
         20        CONCAT                                           ~23     ~20, '%3Cbr%3E'
         21        ECHO                                                     ~23
   65    22        CONCAT                                           ~24     !7, '%3Cbr%3E'
         23        ECHO                                                     ~24
   66    24        ECHO                                                     'https%3A%2F%2Fwww.strava.com%2Foauth%2Fauthorize%3Fclient_id%3D239%26response_type%3Dcode%26redirect_uri%3Dhttp%3A%2F%2Flocalhost%26approval_prompt%3Dforce%3Cbr%3E'
   67    25        ASSIGN                                                   !8, null
   68    26        FETCH_IS                                         ~26     '_GET'
         27        ISSET_ISEMPTY_DIM_OBJ                         0          ~26, 'code'
         28      > JMPZ                                                     ~27, ->33
   69    29    >   FETCH_R                      global              ~28     '_GET'
         30        FETCH_DIM_R                                      ~29     ~28, 'code'
         31        ASSIGN                                                   !8, ~29
         32      > JMP                                                      ->38
   72    33    >   ROPE_INIT                                     3  ~32     '%3Ca+href%3D%27'
         34        ROPE_ADD                                      1  ~32     ~32, !7
         35        ROPE_END                                      2  ~31     ~32, '%27%3EClick+here%3Ca%3E'
         36        CONCAT                                           ~34     ~31, '%3Cbr%3E'
         37        ECHO                                                     ~34
   75    38    >   ECHO                                                     !8
   76    39        ASSIGN                                                   !9, 'https%3A%2F%2Fwwww.strava.com%2Foauth%2Ftoken'
   77    40        ECHO                                                     '%3Cbr%3E'
   78    41        INIT_FCALL                                               'tokenrequest'
         42        SEND_VAR                                                 !0
         43        SEND_VAR                                                 !1
         44        SEND_VAR                                                 !8
         45        DO_FCALL                                      0  $36     
         46        ASSIGN                                                   !10, $36
   79    47        ECHO                                                     '%3Cbr%3E'
   80    48        INIT_FCALL                                               'var_dump'
         49        SEND_VAR                                                 !10
         50        DO_ICALL                                                 
   81    51      > RETURN                                                   1

Function authorizeurl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/81Yi3
function name:  authorizeUrl
number of ops:  18
compiled vars:  !0 = $clientId, !1 = $response_type, !2 = $redirect_uri, !3 = $scope, !4 = $approval_prompt, !5 = $authorizeUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   11     5        ROPE_INIT                                    10  ~7      'https%3A%2F%2Fwww.strava.com%2Foauth%2Fauthorize%3Fclient_id%3D'
          6        ROPE_ADD                                      1  ~7      ~7, !0
          7        ROPE_ADD                                      2  ~7      ~7, '%26response_type%3D'
          8        ROPE_ADD                                      3  ~7      ~7, !1
          9        ROPE_ADD                                      4  ~7      ~7, '%26redirect_uri%3D'
         10        ROPE_ADD                                      5  ~7      ~7, !2
         11        ROPE_ADD                                      6  ~7      ~7, '%26scope%3D'
         12        ROPE_ADD                                      7  ~7      ~7, !3
         13        ROPE_ADD                                      8  ~7      ~7, '%26approval_prompt%3D'
         14        ROPE_END                                      9  ~6      ~7, !4
         15        ASSIGN                                                   !5, ~6
   12    16      > RETURN                                                   !5
   13    17*     > RETURN                                                   null

End of function authorizeurl

Function parsejason:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/81Yi3
function name:  parseJason
number of ops:  6
compiled vars:  !0 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   17     5*     > RETURN                                                   null

End of function parsejason

Function tokenrequest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/81Yi3
function name:  tokenRequest
number of ops:  98
compiled vars:  !0 = $clientId, !1 = $clientSecret, !2 = $code, !3 = $oauthFields, !4 = $oauthFieldsObject, !5 = $parameters, !6 = $ch, !7 = $urlResponse, !8 = $http_response, !9 = $http_decoded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   21     3        FETCH_CONSTANT                                   ~10     'client_id'
          4        INIT_ARRAY                                       ~11     !0, ~10
   22     5        ADD_ARRAY_ELEMENT                                ~11     !1, 'client_secret'
   23     6        ADD_ARRAY_ELEMENT                                ~11     !2, 'code'
   20     7        ASSIGN                                                   !3, ~11
   24     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                                 
   25    11        ECHO                                                     '%3Cbr%3E'
   26    12        CONCAT                                           ~14     '%3Cbr%3E', !3
         13        CONCAT                                           ~15     ~14, '%3Cbr%3E'
         14        ECHO                                                     ~15
   27    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                                 
   29    18        CAST                                          8  ~17     !3
         19        ASSIGN                                                   !4, ~17
   30    20        ECHO                                                     '%3Cbr%3E'
   31    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                                 
   32    24        ECHO                                                     '%3Cbr%3E'
   33    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                                 
   34    28        ECHO                                                     '%3Cbr%3E'
   38    29        INIT_FCALL                                               'http_build_query'
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $21     
         32        CONCAT                                           ~22     '%26', $21
         33        ASSIGN                                                   !5, ~22
   39    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                                 
   40    37        CONCAT                                           ~25     '%3Cbr%3E', !5
         38        ECHO                                                     ~25
   41    39        ECHO                                                     '%3Cbr%3E'
   42    40        INIT_FCALL_BY_NAME                                       'curl_init'
         41        DO_FCALL                                      0  $26     
         42        ASSIGN                                                   !6, $26
   43    43        INIT_FCALL_BY_NAME                                       'curl_setopt'
         44        SEND_VAR_EX                                              !6
         45        FETCH_CONSTANT                                   ~28     'CURLOPT_URL'
         46        SEND_VAL_EX                                              ~28
         47        SEND_VAL_EX                                              'https%3A%2F%2Fwww.strava.com%2Foauth%2Ftoken%3F'
         48        DO_FCALL                                      0          
   44    49        INIT_FCALL_BY_NAME                                       'curl_setopt'
         50        SEND_VAR_EX                                              !6
         51        FETCH_CONSTANT                                   ~30     'CURLOPT_POST'
         52        SEND_VAL_EX                                              ~30
         53        SEND_VAL_EX                                              1
         54        DO_FCALL                                      0          
   45    55        INIT_FCALL_BY_NAME                                       'curl_setopt'
         56        SEND_VAR_EX                                              !6
         57        FETCH_CONSTANT                                   ~32     'CURLOPT_POSTFIELDS'
         58        SEND_VAL_EX                                              ~32
         59        SEND_VAR_EX                                              !5
         60        DO_FCALL                                      0          
   46    61        INIT_FCALL_BY_NAME                                       'curl_setopt'
         62        SEND_VAR_EX                                              !6
         63        FETCH_CONSTANT                                   ~34     'CURLOPT_RETURNTRANSFER'
         64        SEND_VAL_EX                                              ~34
         65        SEND_VAL_EX                                              <true>
         66        DO_FCALL                                      0          
   47    67        INIT_FCALL                                               'var_dump'
         68        SEND_VAR                                                 !6
         69        DO_ICALL                                                 
   49    70        INIT_FCALL_BY_NAME                                       'curl_exec'
         71        SEND_VAR_EX                                              !6
         72        DO_FCALL                                      0  $37     
         73        ASSIGN                                                   !7, $37
   50    74        ECHO                                                     '%3Cbr%3E'
   51    75        INIT_FCALL                                               'var_dump'
         76        SEND_VAR                                                 !7
         77        DO_ICALL                                                 
   52    78        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         79        SEND_VAR_EX                                              !6
         80        FETCH_CONSTANT                                   ~40     'CURLINFO_HTTP_CODE'
         81        SEND_VAL_EX                                              ~40
         82        DO_FCALL                                      0  $41     
         83        ASSIGN                                                   !8, $41
   53    84        INIT_FCALL                                               'json_decode'
         85        SEND_VAR                                                 !8
         86        DO_ICALL                                         $43     
         87        ASSIGN                                                   !9, $43
   54    88        CONCAT                                           ~45     '%3Cbr%3E', !9
         89        ECHO                                                     ~45
   57    90        INIT_FCALL_BY_NAME                                       'curl_close'
         91        SEND_VAR_EX                                              !6
         92        DO_FCALL                                      0          
   58    93        INIT_FCALL                                               'json_decode'
         94        SEND_VAR                                                 !7
         95        DO_ICALL                                         $47     
         96      > RETURN                                                   $47
   60    97*     > RETURN                                                   null

End of function tokenrequest

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.32 ms | 1414 KiB | 23 Q