1
我想在我的本地主機上使用CURL來關注PODIO的REST API調用這個tutorial。 我能夠完成獲取應用程序授權的步驟,並且現在我有URL上的授權代碼。但似乎我沒有得到響應訪問令牌我得到錯誤Undefined property: stdClass::$access_token
使用下面的代碼。當我試圖執行變量$tokenresult
的print_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);
?>