Facebook PHP API错误代码100:API中提供的appsecret_proof无效 [英] Facebook PHP API Error code 100: Invalid appsecret_proof provided in the API

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

问题描述

我正在使用版本4.0的PHP SDK for Facebook。我已经看了下午的更好的一部分,但是我发现与我的问题相关的任何帖子都没有工作或涉及使用旧的SDK版本。

I'm using version 4.0 of the PHP SDK for Facebook. I've looked around for the better part of the afternoon, but any posts I've found related to my problem have either not worked or involved the use of the older SDK versions.

我正在使用FacebookRequest对象向Facebook发送基本的GET请求,但是它返回错误代码100,并显示错误消息API中提供无效的appsecret_proof。

I'm trying to make a basic GET request to facebook using the FacebookRequest object, but it returns an error code 100 with error message "Invalid appsecret_proof provided in the API".

在我的应用设置中,我尝试启用需要appsecret_proof服务器API调用以及禁用它。奇怪的是,这不会改变我收到的错误。

In my app settings I've tried enabling the "require appsecret_proof for server API calls", as well as disabling it. Oddly enough, this doesn't change the error I'm receiving.

编辑:我已经检查了我的应用程序密钥,应用程序秘密和访问令牌,他们都似乎是正确的。

I've double checked my app key, app secret, and access token, they all appear to be correct.

这是我的代码:

require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'Facebook/autoload.php' );

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;

$app_key = 'MYAPP_KEY';
$app_secret = 'MYAPP_SECRET';

$fb_access_token = "MYACCESS_TOKEN";

// init app with app id (APPID) and secret (SECRET)
FacebookSession::setDefaultApplication($app_key,$app_secret);

try {
  $session = new FacebookSession($fb_access_token);
} catch( FacebookRequestException $ex ) {
  // When Facebook returns an error
    echo "Facebook returned a request exception.";
    exit;
} catch( Exception $ex ) {
  // When validation fails or other local issues
    echo "Facebook returned an unspecified exception.";
    exit;
}

try{
    // graph api request for user data
    $request = new FacebookRequest( $session, 'GET', '/me' );
    $response = $request->execute();
    // get response
    $graphObject = $response->getGraphObject();

    // print data
    echo  print_r( $graphObject, 1 );
}catch(FacebookRequestException $e){
    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();
    echo "Raw response: " . $e->getRawResponse();
}

我很失落;我一直在盯着它永远,我找不到它的错误。

I'm at a loss; I've been staring at it for forever and I can't find what's wrong with it.

推荐答案

你可以试试这个:

1.在您的FbApp中禁用需要appsecret_proof服务器API调用

2.在您的代码中,在行的FacebookSession :: setDefaultApplication($ app_key,$ app_secret); < br>
添加以下行:FacebookSession :: enableAppSecretProof(false);

You can try this:
1. In your FbApp disable the "require appsecret_proof for server API calls"
2. In your code, after line FacebookSession::setDefaultApplication($app_key,$app_secret);
add this line: FacebookSession::enableAppSecretProof(false);

这篇关于Facebook PHP API错误代码100:API中提供的appsecret_proof无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆