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 git.master, git.master_jit, rfc.property-hooks
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.24 ms | 403 KiB | 8 Q