什么是通过图形api或FQL按用户ID获取用户的朋友数量的URL

时间:2012-08-22 06:00:17

标签: python facebook-graph-api facebook-fql

嗨,这是我的一段代码,用于通过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)

1 个答案:

答案 0 :(得分:0)

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

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

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

您不应该需要访问令牌来获取friend_count