Problem with access token while creating Facebook Test Users

笑着哭i 提交于 2019-12-04 17:33:20

Here is some working code that will allow you to create a test user with the PHP SDK.

Ensure your access token is properly urlencoded when passing back to facebook.

I was getting this error until I removed some parameters from example code I saw floating around. Here is an example in python using requests that I finally managed to get working:

# Get the access token
resp = requests.get(
    'https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={app_id}&client_secret={app_secret}'.format(
        app_id=APP_ID, # Your app id (found in admin console)
        app_secret=APP_SECRET  # Your app secret (found in admin console)
    )
)
# Parse the token
token = resp.content.split('=')[-1]

# Create the user
data = {'access_token': str(token)}
resp = requests.post(
    'https://graph.facebook.com/{app_id}/accounts/test-users?installed=true'.format(
        app_id=APP_ID
    ),
    data=data
)
print resp.content
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!