How get facebook user ID from my application?

后端 未结 4 1509
傲寒
傲寒 2020-12-21 18:20

I created a facebook application and send request to a user through below code.Now when a user allow my application then i need his id and email address into my canvas url.B

4条回答
  •  不思量自难忘°
    2020-12-21 18:32

    First of all, your code is "badly" written. The catch block in your code "when executed" does not mean that the user is not logged in. It means that something went wrong in your try block (a.k.a bad Facebook Call).

    Now for your question, you just need to place this in your try block:

    $data     =   $facebook->api('/me?fields=id,email');
    

    IMPORTANT NOTE:
    You may not get the user real email, the user may choose to not share it with you and this way Facebook will create a "mirror" email to share with your App.

提交回复
热议问题