我试图在我的localhost上使用CURL关注PODIO的REST API调用ExpressJs
。
我能够完成授权应用程序的步骤,现在我已经获得了URL上的授权代码。但似乎我没有得到访问令牌的响应我使用下面的代码收到错误Undefined property: stdClass::$access_token
。当我尝试print_r
变量$tokenresult
来查看这些令牌响应时,会出现错误unexpected '$token_result' (T_VARIABLE)
。如果您有任何建议,请提前多多谢谢!
<?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);
?>
答案 0 :(得分:2)
您是否考虑过使用Podio PHP客户端? 这应该很好地处理与Podio的整合。
请查看https://github.com/podio/podio-php和http://podio.github.io/podio-php/
答案 1 :(得分:0)