gpt4 book ai didi

facebook - 通过应用程序访问 token 使用 FQL 结交 friend

转载 作者:行者123 更新时间:2023-12-04 10:01:10 24 4
gpt4 key购买 nike

我正在尝试使用 Facebook 查询语言 (FQL) 获取已安装我的应用程序的好友列表。在验证我的应用程序并获取我的应用程序访问 token 后,我正在执行以下查询(注意我正在使用 Java 和 RestFB 来运行):

https://api-read.facebook.com/method/fql.query?query=SELECT+uid+FROM+user+WHERE+uid+IN+%28SELECT+uid2+FROM+friend+WHERE+uid1%3D<userId>%29+AND+is_app_user%3D1&access_token=<appAccessToken>&format=json

这会返回一个错误:

..."error_code":102,"error_msg":"Requires user session"

类似地,如果我尝试将 FQL 与图形 API 结合使用(如下所示),我会遇到同样的错误。

https://graph.facebook.com/fql?q=SELECT+uid+FROM+user+WHERE+uid+IN+%28SELECT+uid2+FROM+friend+WHERE+uid1%3D<userId>%29+AND+is_app_user%3D1&access_token=<appAccessToken>&format=json

所以我尝试使用用户访问 token ,正如预期的那样有效。我搜索了很多并发现了这个: Facebook 'Friends.getAppUsers' using Graph API

它有一些很好的建议,让我尝试了以下查询:

https://graph.facebook.com/<userId>/friends?fields=installed&access_token=<appAccessToken>&format=json

这将返回具有应用访问 token 的好友列表。

这引出了我的问题。为什么我无法通过 FQL 使用应用程序访问 token 来获取 friend 列表,但我可以使用 Graph API 检索 friend ?

提前致谢

最佳答案

首先,我想提醒您,fql.query 来自 REST API,将被弃用。

FB 建议今后使用 GRAPH API..

重要提示:FQL 不会被弃用,只有使用 REST API 的 fql.query 方法会被弃用。

因此您可以继续使用 FQL 并使用 GRAPH API 执行 FQL。

阅读更多 http://developers.facebook.com/docs/reference/fql/

FB 中的示例代码

 //get user access_token
$token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&client_secret=' . $app_secret
. '&code=' . $code;
$access_token = file_get_contents($token_url);

// Run fql query
$fql_query_url = 'https://graph.facebook.com/'
. '/fql?q=SELECT+uid2+FROM+friend+WHERE+uid1=me()'
. '&' . $access_token;
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);

//display results of fql query
echo '<pre>';
print_r("query results:");
print_r($fql_query_obj);
echo '</pre>';

我知道我还没有真正回答你的问题,但这只是一个信息集合,关于哪些信息可以用来与 FB 的变化保持一致。

关于facebook - 通过应用程序访问 token 使用 FQL 结交 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9732214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com