[英]How to post to the Instagram API?
Trying to return a JSON decode of an API curl on instagram, but it's only returning a blank page. 尝试在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;
?>
This will probably generate a warning at the very least if not an error, something like: 这可能至少会产生警告,即使不是错误,例如:
Warning Object of class stdClass could not be converted to string.
Try: 尝试:
var_dump($instagram_string);
Instead of: 代替:
echo $instagram_string;
If you want to echo the string then: 如果要回显字符串,则:
echo $instagram_json;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.