0

嗨,这是我通过 python 获取用户拥有的朋友数量的代码。它什么也不返回。谁能告诉我应该授予哪个访问权限或到目前为止我所做的任何错误?

friend_count = 0
q = urllib.urlencode({'SELECT friend_count FROM user WHERE uid': 784877761})

url = 'https://api.facebook.com/method/fql.query?query=' + q

request = urllib2.Request(url)
data = urllib2.urlopen(request)
doc = parse(data)


friend_count_node = doc.getElementsByTagName("friend_count")
test = friend_count_node[0].firstChild.nodeValue
logging.info(test)
4

1 回答 1

0

尝试用以下代码替换您的代码:

q = urllib.urlencode({'SELECT friend_count FROM user WHERE uid = 784877761'})

url = 'https://graph.facebook.com/fql?q=' + q

您不需要访问令牌即可获取friend_count.

于 2012-08-22T12:08:56.833 回答