我在https://developers.facebook.com/tools/explorer?fql=
中使用了以下查询SELECT aid FROM album WHERE owner = "100001741044617";
我得到了正确的输出。
我尝试通过python使用相同的查询并提取输出我遇到了问题。 我发布了python代码和输出
代码:
import urllib
query = "SELECT aid FROM album WHERE owner = \"100001741044617\""
print(query)
query = urllib.quote(query)
print(query)
url = "https://graph.facebook.com/fql?q=" +query
data = urllib.urlopen(url).read()
print(data)
输出
[root@IN-AIR-BIMAPP106 ~]# python /opt/fql.py
SELECT aid FROM album WHERE owner = "100001741044617"
SELECT%20aid%20FROM%20album%20WHERE%20owner%20%3D%20%22100001741044617%22
{"error":{"message":"A user access token is required to request this resource.","type":"OAuthException","code":102}}
我已经生成了所需的访问令牌user_photoes。 请告诉我该怎么做。感谢。
答案 0 :(得分:1)
访问令牌需要包含在您的查询中。例如,为了得到你所有的朋友:
query = "SELECT uid2 FROM friend WHERE uid1 = me()"
params = urllib.urlencode({'q': query, 'access_token': YOUR_ACCESS_TOKEN})
print params
'q=SELECT+uid2+FROM+friend+WHERE+uid1+%3D+me%28%29&access_token=YOUR_ACCESS_TOKEN'
url = "https://graph.facebook.com/fql?" + params
data = urllib.urlopen(url).read()
print(data)
'{"data":[{"uid2":"#######"},{"uid2":"#######"},{"uid2":"#######"}, ...