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 = “http://dadler.dynalias.org/dwacode/smartthings/exampleOauth.php”;
//STEP 1 - Get Access Code
if(!isset($_REQUEST[‘code’]) && !isset($_REQUEST[‘access_token’]))
{
header( “Location: https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=$client&redirect_uri=".$url."&scope=app” ) ;
}
//STEP 2 - Use Access Code to claim Access Token
else if(isset($_REQUEST[‘code’]))
{
$code = $_REQUEST[‘code’];
$page = “https://graph.api.smartthings.com/oauth/token?grant_type=authorization_code&client_id=".$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

”;
print_r($curlinfo);
curl_close($ch);
if(isset($response[‘access_token’]))
{
//Redirect to self with access token for step 3 for ease of bookmarking
header( “Location: ?access_token=”.$response[‘access_token’] ) ;
}
else
{
print “

error requesting access token…”;
print_r($response);
}

Response:

curl info
Array
(
[url] =>
https://graph.api.smartthings.com/oauth/token?grant_type=authorization_code&client_id=<my_id>&client_secret=<my_secret>&redirect_uri=http://dadler.dynalias.org/dwacode/smartthings/exampleOauth.php&code=rfmr1s&scope=app

[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:
graph.api
and
graph-eu01-euwest1.api

im uk based