本文介绍了图表返回了错误:API参数中提供了无效的appsecret_proof的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook PHP sdk(v4)来获取用户信息,安装SDK之后,我添加代码

i am using facebook PHP sdk (v4) to fetch user information,after installing SDK, i add the code

$fb = new Facebook\Facebook([
  'app_id' => 'my app id',
  'app_secret' => 'my app secret',
  'default_graph_version' => 'v2.5',
]);

try {
  // Returns a `Facebook\FacebookResponse` object
 $access_token= //copied from my https://developers.facebook.com/tools/explorer/
  $response = $fb->get('/me?fields=id,name', '$access_token');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

$user = $response->getGraphUser();

echo 'Name: ' . $user['name'];

但是当我运行页面时,它给了我这个错误,

but when i run the page it gives me this error,

Graph returned an error: Invalid appsecret_proof provided in the API argument

我正在正确复制应用程序密码,这可能是发生此类错误的原因,我该如何解决?

i am copying the app secret correctly, what could be the reason for such error and how should i fix this ?

推荐答案

您可能需要阅读以下内容: https://developers.facebook.com/docs/graph-api/securing-requests

You may want to read this: https://developers.facebook.com/docs/graph-api/securing-requests

appsecret_proof是使用应用程序秘密"生成的单独参数,但不是应用程序秘密".有关如何生成它的信息可以在文档中找到.

appsecret_proof is a separate parameter that is generated by using the App Secret, but it is NOT the App Secret. Information about how to generate it can be found in the docs.

这篇关于图表返回了错误:API参数中提供了无效的appsecret_proof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 18:55