Sample PHP application doesn't work

I created a test smartapp to drive a PHP application but when trying with the sample PHP code, it gets the access code but then doesn’t get the authorization token. There is no error, but no content in the response to get the authorization token.

This is the top of exampleOauth.php followed by the response:
//client id and client secret
$client = ‘<my_id>’;
$secret = ‘<my_secret>’;
//hardcode the full url to redirect to this file
$url = “”;
//STEP 1 - Get Access Code
if(!isset($_REQUEST[‘code’]) && !isset($_REQUEST[‘access_token’]))
header( “Location:$client&redirect_uri=".$url."&scope=app” ) ;
//STEP 2 - Use Access Code to claim Access Token
else if(isset($_REQUEST[‘code’]))
$code = $_REQUEST[‘code’];
$page = “".$client."&client_secret=".$secret."&redirect_uri=".$url."&code=".$code."&scope=app”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $page );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 0 );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
$response = json_decode(curl_exec($ch),true);
$curlinfo = curl_getinfo($ch);
print “curl info

//Redirect to self with access token for step 3 for ease of bookmarking
header( “Location: ?access_token=”.$response[‘access_token’] ) ;
print “

error requesting access token…”;


curl info
[url] =><my_id>&client_secret=<my_secret>&redirect_uri=

[content_type] => 
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.109
[namelookup_time] => 0.047
[connect_time] => 0.078
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array

[redirect_url] => 

error requesting access token…

Did you put the client_id and secret that you generated into these fields?

Yes, for purposes of posting, I removed the actual client and secret values. The first step works with the client value to return the code. But then nothing is returned when the request is made to get the authorization token given the code, client and secret values.

When I put the URL to get the authorization token into the browser, I do get a valid response so it seems that there must be a problem with curl in PHP in this case.

The http_code is coming back as 0 which doesn’t seem right. If I change “https” to “http”, I get an http code of 301 but it still doesn’t work.

bump. exactly same problem

tried both:

im uk based