以下网址是一个带有令牌的Instagram电话,这是我想要的,每次都是新的令牌。
https://api.instagram.com/v1/media/785825990101768657/likes?access_token=1640112569.b7fd4cf.a915d0c8bada4609894807de1616df7b
记下令牌中的句点以使其有效。
有2个auths可用,访问代码:
http://domain.co/instagram.php/?code=3dd01300d63f4685a7ee7b4359821119
哪个失败
https://api.instagram.com/v1/media/785825990101768657/likes?code=3dd01300d63f4685a7ee7b4359821119
错误
{"meta":{"error_type":"OAuthParameterException","code":400,"error_message":"Missing client_id or access_token URL parameter."}}
和一个有效的令牌
https://api.instagram.com/v1/media/785825990101768657/likes?access_token=8515ebebfefa4f0f8b5412d2e834dfc2
但要实现它
https://instagram.com/oauth/authorize/?client_id=333333333333333333&redirect_uri=http://domain.co/instagram.php/?&response_type=token
它返回带有#符号的标记,使其无效。
http://favd.co/instagram.php/#access_token=1640112569.b7fd4cf.a915d0c8bada4609894807de1616df7b
我不能$ _GET到它。
我如何$ _GET到Instagram上的连接哈希令牌/键?
调用代码:
<!DOCTYPE html>
<head>
</head>
<body>
<div id="body">
<div id="mainContainer">
<div class="jumbotron" style="text-align: center; background: none;">
<div class="logo">
<h1 class="welcome">Welcome to</h1>
</div>
<div style="min-height: 100px">
<a href="favd.php">Facebook query object 'likes'!</a>
</br>
<!--
<a href="https://api.instagram.com/oauth/authorize/?client_id=33333333333333333333333333&redirect_uri=http://domain.co/instagram.php/?&response_type=code">Instagram query object 'likes'!</a> -->
<a href="https://instagram.com/oauth/authorize/?client_id=3333333333333333333333&redirect_uri=http://favd.co/instagram.php/?&response_type=token">Instagram query object 'likes'!</a>
<?php
$client_id = '11111111111111111111111';
$client_secret = '222222222222222222222';
$redirect_uri = 'http://favd.co/instagram.php/?';
$scope = 'basic+likes+comments+relationships';
$url = "https://api.instagram.com/oauth/authorize?client_id=$client_id&redirect_uri=$redirect_uri&scope=$scope&response_type=code";
if(!isset($_GET['code']))
{
echo "</br>";
echo '<a href="'.$url.'">Instagram query object \'hearts\'!</a>';
}
else
{
$code = $_GET['code'];
$apiData = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => 'authorization_code',
'redirect_uri' => $redirect_uri,
'code' => $code
);
$apiHost = 'https://api.instagram.com/oauth/access_token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiHost);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$jsonData = curl_exec($ch);
curl_close($ch);
var_dump($jsonData);
$user = @json_decode($jsonData);
echo '<pre>';
print_r($user);
exit;
}
?>
</div>
</div>
</div>
</div>
</body>
</html>