2017-01-01 54 views
1

我想在我的本地主机上使用CURL来关注PODIO的REST API调用这个tutorial。 我能够完成获取应用程序授权的步骤,并且现在我有URL上的授权代码。但似乎我没有得到响应访问令牌我得到错误Undefined property: stdClass::$access_token使用下面的代码。当我试图执行变量$tokenresultprint_r来查看这些令牌响应时,有一个错误unexpected '$token_result' (T_VARIABLE)。您可以提供建议,非常感谢您提前!PODIO API调用使用CURL获取excel,认证错误

<?php 

$ch1 = curl_init('https://podio.com/oauth/token?grant_type=authorization_code&client_id=app_ID_i_got_on_PODIO_API key&redirect_uri=http://localhost/PODIO_API/podio-php/podiocurlrequest.php&client_secret=client_secret_key_i_got_fromPODIO_API_key &code=authorization_i_got_from_the_URL'); 
//curl_setopt($ch1, CURLOPT_TIMEOUT, 400); 
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "POST"); 
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); 
//curl_setopt($ch1, CURLOPT_POSTFIELDS, $data_array); 
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); 
$result1 = curl_exec($ch1); 
curl_close($ch1); 

$tokenresult = json_decode($result1); 

$token = $tokenresult->access_token; 

$token1 = "OAuth2 ".$token; 

$headers = array(
     "Authorization:".$token1 
     ); 

$podioch = curl_init('https://api.podio.com/item/app/my app id here/xlsx/&limit=500'); 
curl_setopt($podioch, CURLOPT_HTTPHEADER, $headers); //load all header data 
curl_setopt($podioch, CURLOPT_CUSTOMREQUEST, "GET"); 
curl_setopt($podioch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($podioch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($podioch, CURLOPT_RETURNTRANSFER, 1); 
$resultdat = curl_exec($podioch); 
curl_close($podioch); 

?> 

回答