Graph API dependant query - facebook

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!

Related

how to divide entities and share it in clean architecture

For my new project in flutter, I am trying to follow the Clean Architecture and diving each different feature in domain, data and presentation`.
Now, I have initiated with the Authentication feature where I have started creating the Entities however, I am pretty much confused and stuck on how to modularize the code based on the Clean Architecture practice.
For example,
The response of my login service is as follow,
so do I need to create entities and models for all JSON nested objects like for response , data , user , accountData and permissions ?
or is there any way to use IResponse to store common elements like status , message and data and then use only for relevant feature.
Not sure whether it is allowed to share entities in between the features. Like user block below can be a feature in Authorization and Employee
{
"status": "success",
"message": "successfully login",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NywiaXNMb2dnZWRJbiI6dHJ1ZSwidGVuYW50SWQiOjEyLCJpYXQiOjE2MjU5OTE5MTAsImV4cCI6MTYyNjA3ODMxMH0.I0z9OIDnQS-MI1ya6usqycoryZ1TBwj3K52BRfrpMuY",
"user": {
"user_id": 7,
"email": "jd#gmail.com",
"first_name": "John",
"last_name": "Doe",
"phone": "",
"date_of_birth": "2015-08-06T00:00:00.000Z",
},
"accountData": {
"name": "Amazon",
"account_id": 1
},
"permissions": [
"ViewAllEmployee",
"AddNewEmployee"
]
}
}

Facebook Graph API - Get user profile from conversations

by using Facebook Graph API I can fetch the conversations between users and my page. One of the returned conversations looks like this:
{
"message": "message content",
"from": {
"name": "My Page's Name",
"email": "198301820627381#facebook.com",
"id": "198301820627381",
},
"to": {
"data": [
{
"name": "John Doe",
"email": "396169264164870#facebook.com",
"id": "396169264164870",
}
]
},
"id": "m_mid.$cAADurJ0X8UhnJ3tfxVg9jYXJW5fp"
}
I see that I got the user's id field. How can I fetch this user's profile (first name, last name, profile pic) base on this field ? (or is there another way ?)
I followed the Graph API's User Reference but all I got are the user's id and name (which I already have from the returned conversation).
profile_pic only works for PSIDs (Messenger bot events), for ASIDs just use the picture field instead

How to get thumbnail of Facebook user's picture, by messenger user id

I have a messenger bot, that receives a user id, which I can then use to send a request to https://graph.facebook.com/v2.10/{user_id}?access_token={token} that returns an object like this:
{
"first_name": {name},
"last_name": {surname},
"profile_pic": "https://scontent.xx.fbcdn.net/v/t1.0-1/{stuff}.jpg?oh={stuff}&oe={stuff}",
"locale": "en_US",
"timezone": 3,
"gender": "male",
"id": {user_id}
}
The profile_pic field contains a url to the full sized profile picture. How do I get a thumbnail?
Requesting
https://graph.facebook.com/v2.10/{user_id}/picture does not work for this ID.So I can't use the parameters for that.
If I request
https://graph.facebook.com/v2.10/{user_id}?fields=profile_pic.width(40).height(40).as(picture_small) the alias works, but the link is still to a full sized picture.

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

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

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.