PHP SDK: How do I capture the access token after user auths app?

后端 未结 4 865
遥遥无期
遥遥无期 2020-12-18 16:26

This is for a canvas app on the Facebook Platform using the new(est) Facebook PHP SDK.

We are using the PHP example from the Facebook tutorial (https://developers.fa

4条回答
  •  感动是毒
    2020-12-18 17:02

    If you want to do this with PHP, you can get the user's access token with a separate call to the Graph API at your redirect_uri. For this you need to change the response_type of your $auth_url in your index page to "code" or "code token".

    Then, at your redirect page, Facebook will add a "code" parameter in the querystring. This API call will return you the full access_token and expiration time:

    https://graph.facebook.com/oauth/access_token?
        client_id=YOUR_APP_ID&
        redirect_uri=YOUR_URL&
        client_secret=YOUR_APP_SECRET&
        code=$_REQUEST['code']
    

    For more information you can refer to the docs on authentication.

提交回复
热议问题