Reputation: 8187
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 ?
Upvotes: 1
Views: 4495
Reputation: 5357
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"}]}
Upvotes: 6
Reputation: 62
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
Upvotes: 2
Reputation: 8995
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.
Upvotes: 1