how to get email id of Facebook user using javascript sdk

前端 未结 6 1106
后悔当初
后悔当初 2020-12-08 04:34

I am using JavaScript API to create my app for Facebook. The problem is, it\'s returning
email = undefined.

I don\'t know why? And if I use Facebo

6条回答
  •  没有蜡笔的小新
    2020-12-08 05:01

    There are a couple of things wrong with your solution. First of all you are using the old authentication scheme. You should use the new one described here : https://developers.facebook.com/docs/reference/javascript/

    You need to add the oauth:true to your init function, and make sure that your getLoginStatus looks for the new type of response.

    When that is said you need to make sure you have the right permissions to see the users e-mail. You can see the required permissions here: http://developers.facebook.com/docs/reference/api/user/

    You get those by using the FB.login function as described by TommyBs in another answer.

    Once you have those options you can use the FB.api function to get the e-mail.

提交回复
热议问题