开发者

How to get a user email from Facebook Graph Api?

开发者 https://www.devze.com 2023-04-09 01:29 出处:网络
I\'m confused开发者_Python百科 here, I\'m trying to get user data using Facebook Api, I\'m requesting email permission using scope=email like this:

I'm confused开发者_Python百科 here,

I'm trying to get user data using Facebook Api, I'm requesting email permission using scope=email like this:

https://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&redirect_uri=MY_URI&scope=email

In Facebook access confirmation window I see that my application requests access to the email, but even after that when I do request to Graph Api it doesn't return the email (it does return all other fields) If I do a request like this:

https://graph.facebook.com/me?fields=id,name,email&access_token=MY_TOKEN

it only returns id and name.


Thank you all guys for your time. It started to work by itself after I deleted the app access from My account in Facebook and then tried to get access again.


Try using c# sdk it's to easy with it. There are some examples in this link.

Hope it helps.


Use the FQL API for this:

query:

select contact_email from user where uid=me()

Call:

https://api.facebook.com/method/fql.query?format=json&query=select+contact_email+from+user+where+uid%3Dme%28%29&access_token=[access_token]


Check whether you have the permission of email or user have unchecked it while approving the request you raised from the URL : facebook.com/dialog/oauth?client_id=MY_APP_ID&redirect_uri=MY_URI&scope=email. You can check using https://graph.facebook.com/me?fields=permissions&access_token=[TOKEN]. It should give you response notifying whether email permission is granted or not like below:

{
    "permissions":{
        "data": [
        {
            "permission": "user_friends",
            "status": "granted"
         },
         {
            "permission": "email",
            "status": "granted"
         },
         {
            "permission": "public_profile",
            "status": "granted"
         }
      ]
   },
   "id": "10207905751235096"
}

check facebook tool explorer for more: https://developers.facebook.com/tools/explorer/


I'm not sure if this is for an app, if so, I had the same problem until I published my app. Check the documentation to see if it applies to you:

https://developers.facebook.com/apps/{your app id}/review-status/

After approved, the email and other sensitive info will show...

0

精彩评论

暂无评论...
验证码 换一张
取 消