FQL 返回“需要有效签名”

发布于 2024-12-09 10:17:03 字数 1493 浏览 0 评论 0原文

我遇到了一个奇怪的问题,之前工作的东西今天停止工作了,也许之前很糟糕,但现在在 oAUTH 2 更改之后,我在接近生产的应用程序上遇到了麻烦,

这就是我尝试

$params = array('method'=>'fql.query','query' => 'SELECT uid2 FROM friend WHERE uid1 = me()');
$result =  $facebook->api($params);

得到的:

Exception: 104: Requires valid signature

或更详细地说:

$config = array(
'appId'  => 'XXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
);

$facebook = new Facebook($config);

$uid = $facebook->getUser();

if ($uid){
 try {
        $access_t = $facebook->getAccessToken();
        $fql = 'SELECT uid2 FROM friend WHERE uid1 = '.$uid;
        $params = array('method' => 'fql.query', 'query' => 'SELECT uid2 FROM friend WHERE uid1 = '.$uid);
        $result = $facebook->api($params);
        echo $result;
        $friends = $facebook->api(array('method' => 'fql.query', 'query' => $fql, 'access_token' => $access_t));
        var_dump($friends);

 } catch (FacebookApiException $e) {
    echo $e; 
 }

这是我用来验证用户并获取登录信息和允许的权限的代码:

$canvas_base_url = "https://apps.facebook.com/myapp/index.php?from=allow";
$params = array('scope' => 'publish_stream,email,offline_access,user_status,friends_status,friends_photos,user_photos,xmpp_login,user_online_presence,friends_online_presence',
'redirect_uri' => $canvas_base_url
);
$loginUrl = $facebook->getLoginUrl($params);

我做错了什么?

I am having a wierd problem, things that worked before stopped working today, maybe it was bad before but now after the oAUTH 2 change, I am having troubles with a near production app

this is what I try

$params = array('method'=>'fql.query','query' => 'SELECT uid2 FROM friend WHERE uid1 = me()');
$result =  $facebook->api($params);

I get:

Exception: 104: Requires valid signature

or more elaborated :

$config = array(
'appId'  => 'XXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
);

$facebook = new Facebook($config);

$uid = $facebook->getUser();

if ($uid){
 try {
        $access_t = $facebook->getAccessToken();
        $fql = 'SELECT uid2 FROM friend WHERE uid1 = '.$uid;
        $params = array('method' => 'fql.query', 'query' => 'SELECT uid2 FROM friend WHERE uid1 = '.$uid);
        $result = $facebook->api($params);
        echo $result;
        $friends = $facebook->api(array('method' => 'fql.query', 'query' => $fql, 'access_token' => $access_t));
        var_dump($friends);

 } catch (FacebookApiException $e) {
    echo $e; 
 }

this is the code I am using to validate the user and get the login info and permissions allowed:

$canvas_base_url = "https://apps.facebook.com/myapp/index.php?from=allow";
$params = array('scope' => 'publish_stream,email,offline_access,user_status,friends_status,friends_photos,user_photos,xmpp_login,user_online_presence,friends_online_presence',
'redirect_uri' => $canvas_base_url
);
$loginUrl = $facebook->getLoginUrl($params);

what am I doing wrong ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏夜暖风 2024-12-16 10:17:03

这意味着您使用的访问令牌无效。它可能已经过期了。

以下是 http://developers.facebook.com/docs/authentication/

除了访问令牌(access_token 参数)之外,
响应包含令牌过期之前的秒数(
过期参数)。一旦令牌过期,您将需要重新运行
上面的步骤生成一个新的代码和access_token,虽然如果
用户已经授权您的应用程序,不会提示他们
再次这样做。如果您的应用需要无限期的访问令牌
时间(也许在用户不同意后代表用户采取行动)
使用您的应用),您可以请求离线访问权限。

因此,您应该重新运行生成访问令牌的步骤,或者需要offline_access 权限。

This means the access token you are using is invalid. It has probably expired.

Here's a quote from the docs at http://developers.facebook.com/docs/authentication/:

In addition to the access token (the access_token parameter), the
response contains the number of seconds until the token expires (the
expires parameter). Once the token expires, you will need to re-run
the steps above to generate a new code and access_token, although if
the user has already authorized your app, they will not be prompted to
do so again. If your app needs an access token with an infinite expiry
time (perhaps to take actions on the user's behalf after they are not
using your app), you can request the offline_access permission.

So you should re-run the steps to generate an access token, or require the offline_access permission.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文