sciyoshi / pyfacebook

PyFacebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Users.isAppAdded is deprecated and removed by facebook

grangier opened this issue · comments

users.isAppUser has to be use instead:
http://wiki.developers.facebook.com/index.php/Users.isAppAdded

Seems that the method takes the same params. Replacing isAppAdded by isAppUser worked for me.

Regards,

Xav

import requests

def check_app_user(user_id, access_token):
    """
    Checks if a user has added the app.

    Args:
    - user_id: The ID of the user to check.
    - access_token: Access token for making the API call.

    Returns:
    - True if the user has added the app, False otherwise.
    """
    api_url = f'https://graph.facebook.com/v12.0/{user_id}/users.isAppUser'
    params = {
        'access_token': access_token
    }
    response = requests.get(api_url, params=params)
    data = response.json()
    return data.get('is_app_user', False)

# Example usage:
user_id = '123456789'  # Replace with the user ID you want to check
access_token = 'your_access_token'  # Replace with your app's access token
is_app_user = check_app_user(user_id, access_token)
print(f"Is the user an app user? {is_app_user}")