【问题标题】:Graph returned an error: Invalid appsecret_proof provided in the API argument图表返回错误:API 参数中提供的 appsecret_proof 无效
【发布时间】:2016-05-12 07:44:59
【问题描述】:

我正在使用 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

我正在正确复制应用程序机密,出现此类错误的原因可能是什么,我应该如何解决这个问题?

【问题讨论】:

  • 请仔细检查您的 clinet_id 和 client_secret。

标签: php facebook facebook-php-sdk


【解决方案1】:

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

appsecret_proof 是使用 App Secret 生成的单独参数,但它不是 App Secret。有关如何生成它的信息可以在文档中找到。

【讨论】:

    【解决方案2】:

    这可能会帮助像我这样登陆这里的人。如果特定 App ID 的 App Secret 错误,也会发生此错误

    【讨论】:

    • 我不小心将 APP_ID 复制到了 APP_SECRET。感谢您的回答。
    【解决方案3】:

    回复晚了,但在我的情况下是另一回事,所以我希望它可以帮助其他人。我看到你评论了:

    //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',
    ]);
    

    如果您选择了另一个应用程序并使用为另一个应用程序提供的访问令牌(基本上是默认的资源管理器应用程序),则创建 appsecret_proof 的哈希将不正确,您将始终看到此错误。

    【讨论】:

      【解决方案4】:

      您需要在 Facebook Graph Explorer 中选择您创建的 APP。我正在选择我的用户名。当我选择应用程序并单击“获取令牌”时,它会从我的应用程序中显示“登录面板”并且可以生成令牌。

      它对我有用。

      【讨论】:

        【解决方案5】:

        或者问题可能是您尚未启用对 Fb 应用的 API 调用。启用 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.
        

        希望能解决问题

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-01-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-07
          • 2013-04-04
          相关资源
          最近更新 更多