使用Instagram基本显示API的“无效平台应用”错误

问题描述 投票:0回答:2

我正在尝试使用Instagram基本显示API,但是当我发布授权代码以获取访问令牌时,我不断收到以下错误{“ error_type”:“ OAuthException”,“ code”:400,“ error_message”:“ Invalid platform app”}

我正在执行此处提到的所有步骤-> https://developers.facebook.com/docs/instagram-basic-display-api/getting-started,是的,我正在使用Instagram应用程序ID,这是产品中的客户端密码-> Instagram->显示,以下是我发送请求的URL

https://api.instagram.com/oauth/access_token?client_id=”。$ app_id。“&client_secret =”。$ app_secret。“&grant_type = authorization_code&redirect_uri =”。$ redirecturi。“&code =”。$ code,

php api facebook-graph-api facebook-apps instagram-graph-api
2个回答
1
投票

交换代码时,您需要使用POST请求。

根据您的网址的外观,您已将它形成为GET请求,并且所有参数都作为网址的一部分而不是表单数据。尝试将参数作为帖子正文的一部分发送]


0
投票

工作示例代码:

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.instagram.com/oauth/access_token",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('client_id' => '{client_id}','client_secret' => '{client_secret}','grant_type' => 'authorization_code','redirect_uri' => '{redirect_uri}','code' => '{code}),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: multipart/form-data; boundary=--------------------------780367731654051340650991"
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
© www.soinside.com 2019 - 2024. All rights reserved.