如何在Python中进行FQL查询?

发布于 2024-11-26 11:25:09 字数 388 浏览 0 评论 0原文

假设用户已经使用 javascript SDK 进行了身份验证,您将如何在 python 中执行 FQL 查询 ->

 query = 'SELECT page_id FROM page_admin WHERE uid = ' + user_id

我已阅读文档,看来您必须点击此网址 ->

https://api.facebook.com/method/fql.query?query=QUERY

你是如何做到这一点的?另外,您是否需要在网址中传递访问令牌,如果是,那么如何传递?

Assuming that the user is already authenticated using the javascript SDK, how would you execute FQL queries in python ->

 query = 'SELECT page_id FROM page_admin WHERE uid = ' + user_id

I've read the documentation and it seems that you got to hit this url ->

https://api.facebook.com/method/fql.query?query=QUERY

How do you do this? Also do you need to pass the access token in the url, if yes then how ?

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

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

发布评论

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

评论(3

与酒说心事 2024-12-03 11:25:09
import urllib

query = "SELECT name FROM user WHERE uid = \"4\""
print(query) 

query = urllib.quote(query)
print(query) 

url = "https://graph.facebook.com/fql?q=" + query
data = urllib.urlopen(url).read()
print(data)

输出:

SELECT name FROM user WHERE uid = "4"
SELECT%20name%20FROM%20user%20WHERE%20uid%20%3D%20%224%22
{"data":[{"name":"Mark Zuckerberg"}]}

FQL 参考

import urllib

query = "SELECT name FROM user WHERE uid = \"4\""
print(query) 

query = urllib.quote(query)
print(query) 

url = "https://graph.facebook.com/fql?q=" + query
data = urllib.urlopen(url).read()
print(data)

output:

SELECT name FROM user WHERE uid = "4"
SELECT%20name%20FROM%20user%20WHERE%20uid%20%3D%20%224%22
{"data":[{"name":"Mark Zuckerberg"}]}

FQL reference

撩动你心 2024-12-03 11:25:09

对于 https://api.facebook.com/method/fql.query?query=查询
将 QUERY 替换为 FQL,
例如:https://api.facebook.com/method/fql.query?query=SELECT%20aid,%20owner,%20name,%20object_id%20FROM%20album%20WHERE%20aid=%2220531316728_324257%22

for https://api.facebook.com/method/fql.query?query=QUERY
Replace QUERY with FQL,
for example:https://api.facebook.com/method/fql.query?query=SELECT%20aid,%20owner,%20name,%20object_id%20FROM%20album%20WHERE%20aid=%2220531316728_324257%22

孤君无依 2024-12-03 11:25:09

您应该使用 urllib2,检查 urlopen 方法。

您将需要访问令牌,具体取决于您正在执行的查询,例如,如果您想检索相册,则需要访问令牌以及 user_photos 和friend_photos 权限,以检索一些您不需要的粉丝页面信息。

You should use urllib2, check the urlopen method.

You would need access token depending on the query you are doing, for example if you want to retrieve an photo album you would need the access token and user_photos and friend_photos permissions, for retrieving some fan page information you don't need any.

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