Frage

I am currently trying to use PyFacebook to retrieve a list of friends currently using an app. With the Python code below, I can retrieve the entire list of friends with their names and uids after performing a login:

# 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()

This is great, but now I need only the friends who are currently using the app with the specified API_KEY and SECRET_KEY. Does anyone know how to do this in PyFacebook?

War es hilfreich?

Lösung

You will need to check for the installed parameter, so something like

friends = facebook.users.getInfo(friends[0:], ['name', 'birthday','installed'])
for friend in friends:
    if 'birthday' in friend:
        if 'installed' in friend:
            print friend
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top