我目前正在尝试使用 PyFacebook 来检索当前使用应用程序的朋友列表。使用下面的 Python 代码,我可以在登录后用他们的名字和 uid 检索整个朋友列表:
# Desktop Application example
def desktop_app():
from facebook import Facebook
# Get api_key and secret_key from a file
facebook = Facebook('API_KEY','SECRET_KEY')
facebook.auth.createToken()
# Show login window
facebook.login()
# Login to the window, then press enter
print 'After logging in, press enter...'
raw_input()
facebook.auth.getSession()
info = facebook.users.getInfo([facebook.uid], ['name', 'birthday', 'affiliations','sex'])[0]
for attr in info:
print '%s: %s' % (attr, info[attr])
friends = facebook.friends.get()
friends = facebook.users.getInfo(friends[0:], ['name', 'birthday'])
for friend in friends:
if 'birthday' in friend:
print friend
if __name__=="__main__":
desktop_app()
这很好,但现在我只需要当前正在使用具有指定 API_KEY 和 SECRET_KEY 的应用程序的朋友。有谁知道如何在 PyFacebook 中做到这一点?