FQL返回“需要有效签名". [英] FQL returns "Requires valid signature"

查看:53
本文介绍了FQL返回“需要有效签名".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个棘手的问题,在今天停止工作之前可以正常工作的东西,也许以前没问题,但是现在在更改oAUTH 2之后,我在生产量产的应用程序上遇到了麻烦

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

这就是我尝试的

$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; 
 }

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

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);

我在做什么错了?

推荐答案

这表示您使用的访问令牌无效.它可能已过期.

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

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

除了访问令牌(access_token参数)外,响应包含令牌到期前的秒数(expires参数).令牌过期后,您将需要重新运行上面的步骤生成新代码和access_token,尽管如果用户已经授权了您的应用程序,则不会提示他们再做一次.如果您的应用需要无限期的访问令牌时间(可能是在用户未采取行动之后代表他们采取行动)使用您的应用程序),您可以请求offline_access权限.

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.

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

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

这篇关于FQL返回“需要有效签名".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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