3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $client_secret in /in/N2fIZ on line 53 <br> Warning: Undefined variable $client_id in /in/N2fIZ on line 55 Warning: Undefined variable $response_type in /in/N2fIZ on line 55 Warning: Undefined variable $redirect_uri in /in/N2fIZ on line 55 Warning: Undefined variable $scope in /in/N2fIZ on line 55 Warning: Undefined variable $approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Warning: Undefined variable $client_id in /in/N2fIZ on line 70 Warning: Undefined variable $client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br> Warning: Array to string conversion in /in/N2fIZ on line 18 <br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)#1 (3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br>string(1) "&" <br>&<br> Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/N2fIZ:34 Stack trace: #0 /in/N2fIZ(70): tokenRequest(NULL, NULL, NULL) #1 {main} thrown in /in/N2fIZ on line 34
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br> Notice: Array to string conversion in /in/N2fIZ on line 18 <br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)#1 (3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br>string(1) "&" <br>&<br> Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/N2fIZ:34 Stack trace: #0 /in/N2fIZ(70): tokenRequest(NULL, NULL, NULL) #1 {main} thrown in /in/N2fIZ on line 34
Process exited with code 255.
Output for 7.3.32 - 7.3.33
<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br>array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br><br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)#1 (3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br>string(1) "&" <br>&<br> Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/N2fIZ:34 Stack trace: #0 /in/N2fIZ(70): tokenRequest(NULL, NULL, NULL) #1 {main} thrown in /in/N2fIZ on line 34
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br> Notice: Array to string conversion in /in/N2fIZ on line 18 <br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)#1 (3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br>string(1) "&" <br>&<br> Fatal error: Call to undefined function curl_init() in /in/N2fIZ on line 34
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br><br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)#1 (3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br>string(1) "&" <br>&<br> Fatal error: Call to undefined function curl_init() in /in/N2fIZ on line 34
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br><br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)#1 (3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br>string(1) "&" <br>&<br> Fatal error: Call to undefined function curl_init() in /in/N2fIZ on line 34
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br><br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br> Fatal error: Call to undefined function: http_build_query() in /in/N2fIZ on line 30
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br><br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br> Fatal error: Call to undefined function: http_build_query() in /in/N2fIZ on line 30
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Undefined variable: client_secret in /in/N2fIZ on line 53 <br> Notice: Undefined variable: client_id in /in/N2fIZ on line 55 Notice: Undefined variable: response_type in /in/N2fIZ on line 55 Notice: Undefined variable: redirect_uri in /in/N2fIZ on line 55 Notice: Undefined variable: scope in /in/N2fIZ on line 55 Notice: Undefined variable: approval_prompt in /in/N2fIZ on line 55 <a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br>https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt=<br>https://www.strava.com/oauth/authorize?client_id=239&response_type=code&redirect_uri=http://localhost&approval_prompt=force<br><a href='https://www.strava.com/oauth/authorize?client_id=&response_type=&redirect_uri=&scope=&approval_prompt='>Click here<a><br><br> Notice: Undefined variable: client_id in /in/N2fIZ on line 70 Notice: Undefined variable: client_secret in /in/N2fIZ on line 70 array(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br><br>Array<br>Array ( [client_id] => [client_secret] => [code] => ) <br>object(stdClass)(3) { ["client_id"]=> NULL ["client_secret"]=> NULL ["code"]=> NULL } <br>stdClass Object ( [client_id] => [client_secret] => [code] => ) <br> Fatal error: Call to undefined function: http_build_query() in /in/N2fIZ on line 30

preferences:
267.41 ms | 404 KiB | 315 Q