脚本宝典收集整理的这篇文章主要介绍了php – 使用cURL请求instagram api acces令牌,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
curl -F 'client_id=CLIENT_ID' \ -F 'client_secret=CLIENT_SECRET' \ -F 'grant_tyPE=authorization_code' \ -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \ -F 'code=CODE' \ https://api.instagram.COM/oauth/access_token
这是我的代码
<body> <?PHP $curl = curl_init(); curl_setopt($curl,CURLOPT_URL,"https://api.instagram.com/oauth/access_token"); curl_setopt($curl,CURLOPT_POST,true); curl_setopt($curl,CURLOPT_POSTFIELDS,"client_id=MYID& client_secret=MY_CLIENT_SECRET&grant_type=authorization_code& redirect_uri=http://localhost/PRuebainst/pruebas.PHP&code=".$_GET['code']); curl_setopt($curl,CURLOPT_RETURNtransfer,CURLOPT_TIMEOUT,10); $output = curl_exec($curl); curl_close($curl); echo ($output); ?> </body>
使用此代码,我从curl请求中得不到任何结果
$client_id = 'YOUR CLIENT ID'; $client_secret ='YOUR CLIENT SECRET'; $redirect_uri = 'YOUR REDIRECT URI'; $auth_request_url = 'https://api.instagram.com/oauth/authorize/?client_id='.$client_id.'&redirect_uri='.$redirect_uri .'&response_type=token'; /* Send user to authorisation */ header("Location: ".$auth_request_url);
此外,如果您希望以编程方式使用此访问令牌
$client_id = 'YOUR CLIENT ID'; $client_secret ='YOUR CLIENT SECRET'; $redirect_uri = 'YOUR REDIRECT URI'; $code ='Enter your code manually'; $url = "https://api.instagram.com/oauth/access_token"; $access_token_parameters = array( 'client_id' => $client_id,'client_secret' => $client_secret,'grant_type' => 'authorization_code','redirect_uri' => $redirect_uri,'code' => $code ); $curl = curl_inIT($url); // we init curl by passing the url curl_setopt($curl,true); // to send a POST request curl_setopt($curl,$access_token_parameters); // indicate the data to send curl_setopt($curl,1); // to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly. curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false); // to stop cURL From verifying the peer's certificate. $result = curl_exec($curl); // to perform the curl session curl_close($curl); // to close the curl session @R_406_647@($result);
以上是脚本宝典为你收集整理的php – 使用cURL请求instagram api acces令牌全部内容,希望文章能够帮你解决php – 使用cURL请求instagram api acces令牌所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。