Php Instagram authenticaton是否用于自动订阅?
我试图从Instagram订阅源中获取照片,但每次我都必须登录我的身份验证弹出窗口,尽管我使用DB的访问令牌Php Instagram authenticaton是否用于自动订阅?,php,instagram,Php,Instagram,我试图从Instagram订阅源中获取照片,但每次我都必须登录我的身份验证弹出窗口,尽管我使用DB的访问令牌 //FIRST TIME $array = array( 'client_id'=>'XXX', 'client_secret' => 'XXX', 'grant_type' => 'authorization_code', 'redirect_uri' => REDIRECT_URL,
//FIRST TIME
$array = array(
'client_id'=>'XXX',
'client_secret' => 'XXX',
'grant_type' => 'authorization_code',
'redirect_uri' => REDIRECT_URL,
'code' => $_GET['code']
);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POSTFIELDS, $array);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
$access_token = $res['access_token'];
//SAVE ACCESS_TOKEN INTO DB
//NEXT TIME
$url = 'https://api.instagram.com/v1/users/self/feed?access_token='.$db['access_token'].'&client_id='.$array['client_id'].'&client_secret='.$array['client_secret'];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
我做错了什么?对不起,上面几行有个错误。 我每次都请求
code
,这个重定向显示了登录表单
之前:
if(!isset($_GET['code'])) {
header('location: https://api.instagram.com/oauth/authorize/?client_id=xxx&redirect_uri='.REDIRECT_URL.'&response_type=code');
}else{
$url = 'https://api.instagram.com/oauth/access_token/';
// ...
if(!isset($_GET['code']) && !isset($access_token) ) {
header('location: https://api.instagram.com/oauth/authorize/?client_id=xxx&redirect_uri='.REDIRECT_URL.'&response_type=code');
}else{
$url = 'https://api.instagram.com/oauth/access_token/';
// ...
之后:
if(!isset($_GET['code'])) {
header('location: https://api.instagram.com/oauth/authorize/?client_id=xxx&redirect_uri='.REDIRECT_URL.'&response_type=code');
}else{
$url = 'https://api.instagram.com/oauth/access_token/';
// ...
if(!isset($_GET['code']) && !isset($access_token) ) {
header('location: https://api.instagram.com/oauth/authorize/?client_id=xxx&redirect_uri='.REDIRECT_URL.'&response_type=code');
}else{
$url = 'https://api.instagram.com/oauth/access_token/';
// ...
现在它工作正常。仔细检查$db['access_token']的值;它通过了吗?
$db['access\u token']
正确。为了进行测试,我将值存储在一个变量中。是否可以直接在浏览器中复制粘贴请求url,然后查看您得到了什么?