Graph returned an error: Invalid appsecret_proof provided in the API argument
Graph returned an error: Invalid appsecret_proof provided in the API argument
我正在使用 facebook PHP sdk (v4) 来获取用户信息,
安装SDK后,我添加代码
$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'];
但是当我 运行 页面时它给我这个错误,
Graph returned an error: Invalid appsecret_proof provided in the API argument
我正在正确复制应用程序密码,出现此类错误的原因可能是什么,我该如何解决?
您可能想阅读此内容:https://developers.facebook.com/docs/graph-api/securing-requests
appsecret_proof
是使用App Secret生成的一个单独的参数,但它不是App Secret。有关如何生成它的信息可以在文档中找到。
这可能会对像我一样来到这里的人有所帮助。如果特定 App ID 的 App Secret 错误,也会发生此错误
回复晚了,但对我来说是另外一回事,所以我希望它能帮助到其他人。我看到你评论了:
//copied from my https://developers.facebook.com/tools/explorer/
在资源管理器工具的右上角,确保所选 Application
与您正在使用的相同:
$fb = new Facebook\Facebook([
'app_id' => 'my app id',
'app_secret' => 'my app secret',
'default_graph_version' => 'vX.Y',
]);
如果您选择了另一个应用程序并使用为另一个应用程序提供的访问令牌(基本上是默认的 Explorer 应用程序),创建 appsecret_proof
的哈希将不正确,您将始终看到此错误。
您需要在 Facebook Graph Explorer 中 select 您创建的应用程序。我正在 select 输入我的用户名。当我 select 编辑应用程序并单击 "Get token" 时,它会显示我的应用程序 "login panel" 并且可以生成令牌。
对我有用。
或者问题可能是您没有启用 API 调用您的 Facebook 应用程序。要启用 Api 调用:
1. Go to your apps section
2. Select the app that you want to use for the intergration
3. Under the App setting select advanced
4. Under security, ensure that the Allow API Access to App Settings is enebale
to yes
5. If need be enable any other permission that might be required.
希望能解决问题
我正在使用 facebook PHP sdk (v4) 来获取用户信息, 安装SDK后,我添加代码
$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'];
但是当我 运行 页面时它给我这个错误,
Graph returned an error: Invalid appsecret_proof provided in the API argument
我正在正确复制应用程序密码,出现此类错误的原因可能是什么,我该如何解决?
您可能想阅读此内容:https://developers.facebook.com/docs/graph-api/securing-requests
appsecret_proof
是使用App Secret生成的一个单独的参数,但它不是App Secret。有关如何生成它的信息可以在文档中找到。
这可能会对像我一样来到这里的人有所帮助。如果特定 App ID 的 App Secret 错误,也会发生此错误
回复晚了,但对我来说是另外一回事,所以我希望它能帮助到其他人。我看到你评论了:
//copied from my https://developers.facebook.com/tools/explorer/
在资源管理器工具的右上角,确保所选 Application
与您正在使用的相同:
$fb = new Facebook\Facebook([
'app_id' => 'my app id',
'app_secret' => 'my app secret',
'default_graph_version' => 'vX.Y',
]);
如果您选择了另一个应用程序并使用为另一个应用程序提供的访问令牌(基本上是默认的 Explorer 应用程序),创建 appsecret_proof
的哈希将不正确,您将始终看到此错误。
您需要在 Facebook Graph Explorer 中 select 您创建的应用程序。我正在 select 输入我的用户名。当我 select 编辑应用程序并单击 "Get token" 时,它会显示我的应用程序 "login panel" 并且可以生成令牌。
对我有用。
或者问题可能是您没有启用 API 调用您的 Facebook 应用程序。要启用 Api 调用:
1. Go to your apps section
2. Select the app that you want to use for the intergration
3. Under the App setting select advanced
4. Under security, ensure that the Allow API Access to App Settings is enebale
to yes
5. If need be enable any other permission that might be required.
希望能解决问题