![](/img/trans.png)
[英]how to post a like or delete an instagram like using instagram api?
[英]How to post to the Instagram API?
尝试在instagram上返回API curl的JSON解码,但仅返回空白页。
<?php
$instagram_username = "devrXXXXXX";
$instagram_client_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$instagram_client_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$instagram_redirect_uri = 'http://production.devr.me/XXXXXXXXX/index.php';
$url = "https://api.instagram.com/oauth/access_token";
$access_token_parameters = array(
'client_id' => $instagram_client_id,
'client_secret' => $instagram_client_secret,
'grant_type' => 'authorization_code',
'redirect_uri' => $instagram_redirect_uri,
'code' => $_GET["code"]
);
$curl = curl_init($url);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$access_token_parameters);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$instagram_json = curl_exec($curl);
$instagram_string = json_decode($instagram_json);
echo $instagram_string;
?>
这可能至少会产生警告,即使不是错误,例如:
Warning Object of class stdClass could not be converted to string.
尝试:
var_dump($instagram_string);
代替:
echo $instagram_string;
如果要回显字符串,则:
echo $instagram_json;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.