The following url is an Instagram call with a token which is what I am trying to get to, a new token each time.
https://api.instagram.com/v1/media/785825990101768657/likes?access_token=1640112569.b7fd4cf.a915d0c8bada4609894807de1616df7b
note the periods in the token to make it work.
There are 2 auths available, an access code:
http://domain.co/instagram.php/?code=3dd01300d63f4685a7ee7b4359821119
Which fails
https://api.instagram.com/v1/media/785825990101768657/likes?code=3dd01300d63f4685a7ee7b4359821119
error
{"meta":{"error_type":"OAuthParameterException","code":400,"error_message":"Missing client_id or access_token URL parameter."}}
and a token, which works
https://api.instagram.com/v1/media/785825990101768657/likes?access_token=8515ebebfefa4f0f8b5412d2e834dfc2
But to get to it
https://instagram.com/oauth/authorize/?client_id=333333333333333333&redirect_uri=http://domain.co/instagram.php/?&response_type=token
It returns the token with a # symbol rendering it useless.
http://favd.co/instagram.php/#access_token=1640112569.b7fd4cf.a915d0c8bada4609894807de1616df7b
I cannot $_GET to it.
How do I $_GET to the concatenated hash token/key on Instagram?
calling code:
<!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>