how to query facebook user's email using graph api? - email

i need help to get facebook user's email. here's what I did.
https://graph.facebook.com/me?scope=email&access_token=xxxxxxxxxxxxxxxx
the result I got back has no email in it.
{
"id": "7027110",
"name": "John Mike",
"first_name": "John",
"last_name": "Mike",
"link": "http://www.facebook.com/john.mike",
"username": "john.mike",
"location": {
"id": "11241875545",
"name": "Oakland, New Jersey"
},
"gender": "male",
"timezone": -5,
"locale": "en_US",
"verified": true,
"updated_time": "2011-12-07T16:53:47+0000"
}
also tried to change scope=email to fields=email, still does not work. whats missing, please help me out

You can get user email like this:
https://graph.facebook.com/v2.5/me?fields=id,name,email
more detail go here

Did you obtain the email extended permission from the user? You can check which permissions your access token has been granted with a call to /me/permissions

The user has to authorize you to get this information first. If it were possible, we would be receiving 100 times more spam than we already receive.
This Facebook tool can help you.

Related

Graph API dependant query

Having the facebook username, I need the user ID to access his feed, so right now I'm using this call:
https://graph.facebook.com/john.doe
which returns something like:
{
"id": "612029xxx",
"first_name": "John",
"gender": "male",
"last_name": "Doe",
"link": "https://www.facebook.com/john.doe",
"locale": "en_US",
"name": "John Doe",
"username": "john.doe"
}
there I use the id to get links:
https://graph.facebook.com/612029xxx/links/?access_token=xxx
But I would like to make a batch request with a dependant query to make just one call:
https://graph.facebook.com/batch=[{"method":"GET","name":"do-me-first","relative-url":"?id=john.doe",{"method":"GET","relative-url":"links","depends-on":"do-me-first"}}]&access_token=xxx
but it gives me an error: Cannot query users by their username (john.doe).
Why can I access the user info with the username in the single call, and not in the dependant one??
P.S.: Probably the second query hasn't been properly constructed, but since it is giving me this first error, I couldn't know!

How To User Fetch Friends Data Using Graph API

What i Need:
i need to fetch my friends like email ,id , name .
i have tried using https://developers.facebook.com/tools/explorer/1456/?method=GET&path=me&version=v2.1.
url is like graph.facebook.com/v2.1/me .
data
{
"id": "77",
"email": "af55#gmail.com",
"first_name": "Mo",
"gender": "male",
"interested_in": [
"female"
],
"last_name": "f",
"link": "https://www.facebook.com/app_scoped_user_id/777/",
"locale": "en_GB",
"name": "singh",
"timezone": 5.5,
"updated_time": "2014-08-18T05:34:55+0000",
"verified": true
}
but making call graph.facebook.com/v2.1/user
Error
{
"error": {
"message": "(#803) Cannot query users by their username (user)",
"type": "OAuthException",
"code": 803
}
}
i have refer the url https://developers.facebook.com/docs/graph-api/reference/v2.1/user.
i have tried to solve by go ->getACEESS TOKEN->check on permissions->email->user_friends.
but still i cannot fetch url through user.
making call with me/friends
{
"data": [
{
"name": "Ashwani Gaur",
"id": "62036"
},
{
"name": "Shobhit Puri",
"id": "131"
},
{
"name": "Rahul Raman",
"id": "10007"
},
{
"name": "Piyush Agarwal",
"id": "800899"
},
{
"name": "Neeraj Yadav",
"id": "10000"
}
],
"paging": {
"next": "https://graph.facebook.com/v2.1/777009872366669/friends?limit=5000&offset=5000&__after_id=enc_AeytV0frT0k1mTj0ZfZRTxPsdSP3TVT_Qd-I1Aoc8vA8YseN4Rr8Vg5n6RgECxsd6RXaVNL8fJ0iaI79qEW7K8nw"
},
"summary": {
"total_count": 383
}
}
i need id, name, email, friend personal_info.
Since April 2014 (v2.0), there are no friend permissions anymore and it´s not possible to get user data from people who don´t use the App. See the changelog for more information: https://developers.facebook.com/docs/apps/changelog
The docs are a bit misleading, you can only use /me to get data of the user who is logged in at the moment.
Update:
By requesting /me/friends, you get all the friends using the App. But as i said in my first sentence, there are no friend permissions anymore. You will only get ID and name of your friends, nothing else. Even if your friend authorized your App, you can ONLY get more data with his own session and by calling /me. The email permission only gives you access to the email of the user who is logged in, not access to the emails of all his friends, of course.
You can only store the email after authorizing a user, that is the only way for other users to get the email of his friends - at least the ones who authorized your App too.

Sharing Spotify link to Facebook and retrieving the link from graph api?

I have posted a link to a spotify track on my facebook account - something like this:
http://open.spotify.com/track/0aXxt38KBHHSmwNsHtIonU
Facebook appears to pick up the link (I get the track image and other data appearing in my feed)
But when I make a request to it via /me/feed in the graph api, there's no link or data relating to the track itself. All I get back is object that looks like this:
..{
"id": "{{some_id}}",
"from": {
"id": "{{my_id}}",
"name": "Si Davies"
},
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/y0/r/nAApRnfWfNW.gif",
"actions": [
{
"name": "Comment",
"link": "{{link to the post}}"
},
{
"name": "Like",
"link": "{{link to the post}}"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "shared_story",
"created_time": "2014-06-17T02:17:06+0000",
"updated_time": "2014-06-17T02:17:06+0000"
}...
Which isn't much use to me - I've tried specifying a link field with something like me/feed?fields=link and also mucked around granting various permissions with little or no effect.. how can I see what spotify track was added to my feed from the graph api?
Spotify seems to use the global music.listens Facebook OpenGraph action. Have a look at https://developers.facebook.com/docs/opengraph/music/
You should be able to retrieve your data by issuing
GET /me/music.listens
according to the docs at https://developers.facebook.com/docs/reference/opengraph/action-type/music.listens#read Remember to grant the user_actions.music permission to be able to read the data (https://developers.facebook.com/docs/facebook-login/permissions/v2.0#reference-opengraph)

Facebook test user - graph api does not return first name and last name

For a few days now, I am suddenly experiencing a strange behavior with the graph API access test users' friends.
When fetching the user objects of friends of my test user (which are test users as well), the first name and last name data is missing.
When I use the browser with
https://graph.facebook.com/100001234567890
I get the response
{
"id": "100001234567890",
"name": "Dorothee Chengman",
"first_name": "Dorothee",
"last_name": "Chengman",
"link": "http://www.facebook.com/people/Dorothee-Chengman/100001234567890",
"gender": "female",
"locale": "de_DE"
}
But when accessing it in my app with a request
https://graph.facebook.com/100001234567890?access_token=imagineTokenHere&format=json
I get the response
{
"id": "100001234567890",
"link": "http://www.facebook.com/profile.php?id=100001234567890",
"birthday": "11/03/1980",
"gender": "female",
"locale": "de_DE",
"updated_time": "2011-12-04T16:48:17+0000"
}
So, suddenly, the first name and last name are missing :-(
Please help.
This is a known issue, being tracked in the bug tracker, it should only affect test users:
https://developers.facebook.com/bugs/320132691332575

Given a Facebook username, how do I get the ID of the profile?

I want the ID, not the username. But given the username...what do I have to do?
https://graph.facebook.com/username
e.g.
https://graph.facebook.com/boxoft
{
"id": "1264933131",
"name": "Box He",
"first_name": "Box",
"last_name": "He",
"link": "http://www.facebook.com/boxoft",
"username": "boxoft",
"gender": "male",
"locale": "en_US"
}
You wont be able to get an exact match but will get some results. Via Graph Api docs
https://graph.facebook.com/search?q=Owalla&type=user