Facebook graph api: Can i use /search and /{id} in 1 request? - facebook

Is it possible to call /search and /{id} in 1 request instead of 2? where id is a result of /search?
If so, would i be limited to the id of the first result, or could i call /{id} for each /search result

This depends on the search type, for example if you search for a User via first/last name like
/search?type=user&q=Mark%20Zuckerberg&fields=id,first_name,last_name,name,link
you can specify the fields parameter with the fields you want to query. The result look like:
{
"data": [
{
"id": "10101640953722381",
"first_name": "Mark",
"last_name": "Zuckerberg",
"name": "Mark Zuckerberg",
"link": "https://www.facebook.com/app_scoped_user_id/10101640953722381/"
},
...
]
}
Keep in mind that you only can access public fields with the search.

Related

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

Facebook Graph API returns different Place name based on query

When using the Facebook Graph API Explorer:
Requesting an Event with this:
/808892439234256?fields=place{name}
Returns this:
{
"place": {
"name": "Cleveland",
"id": "105653772801120"
},
"id": "808892439234256"
}
But requesting the Place (of the Event) with this:
/105653772801120?fields=name
Returns this:
{
"name": "Ohio City, Cleveland",
"id": "105653772801120"
}
Why are the Place names different? Is there a way to return the complete place name in the event instead of having to query the Place, without using FQL?

Facebook Graph API does not return full post data

I'm using the Facebook Graph API to fetch a public page feed. I created a basic application to get appId and secret. When I make a call to PUBLIC_PAGE_ID/feed I can retrieve the correct list of posts in JSON, but they are missing all the field I need, described in docs, and only have message, created_time and id:
{
"data": [
{
"message": "...",
"created_time": "2015-06-11T07:57:05+0000",
"id": "23X12XXXXXX9836_11XXXXXXXX610XXXX52"
},
...
Why all other data isn't there?
The response to your query: /id/feed is the default response. To access more data, you have to pass a fields parameter with the keyword of data you would like to retrieve.
For example: <id>/feed?fields=id,message,picture,shares
This will return:
{
"data": [
{
"id": "1234567890",
"message": "Message",
"picture": "http://fbcdn.com/xxxxxx.jpg",
"shares": {
"count": 0
}
}
}
What I could figure out is you should submit the app for review with at least one permission what your app still needs and then you will get back every data what you ask in the fields parameter.

what is the REST url endpoint standard for download

I know it is HTTP GET rest type to get all or a particular resource details in REST webservices. What if i need to create a rest webservice which downloads a list of employee (filtered by search criteria) details into a file? It must be a GET call but how does the endpoint URL will look like?
//baseurl/employee/download?q=searchParam
Is this correct way to having my endpoint URL?
There is no specific 'download' concept in REST. Normally you have a collection resource
GET /baseurl/employee
that returns a lis of employyes:
[
{
"id": 123,
"firstName": "John",
"lastName": "Doe"
},
{
"id": 456,
"firstName": "Jahn",
"lastName": "Spencer"
}
]
You can filter this list using a query parameter:
GET /baseurl/employee?firstName=John
[
{
"id": 123,
"firstName": "John",
"lastName": "Doe"
}
]
That's it. The client can do what he wants with this response.
If the server supports multiple representations like JSON and XML, the client can request the representation he wants.

Has Facebook deprecated the /EVENT_ID/invited part of their API?

I'm trying to figure out how to access the guest list data of an event on Facebook and the example given in the Facebook documentation located at https://developers.facebook.com/docs/reference/api/event/ is:
https://graph.facebook.com/331218348435/invited
However, when I test this in the explorer I get:
{
"error": "Request failed"
}
Am I missing something?
The endpoint is most definitely not deprecated.
The problem here is that there are simply too many people invited to that event! There are too many results to return in a single query...
If you specify a limit you will get the results you need:
https://graph.facebook.com/331218348435/invited?limit=10
The response for that request would be something like this :
{
"data": [
{
"name": "xxx",
"rsvp_status": "attending",
"id": "111"
},
{
"name": "yyy",
"rsvp_status": "attending",
"id": "222"
},
... (8 more results) ...
],
"paging": {
"next": "https://graph.facebook.com/331218348435/invited?limit=10&offset=10&__after_id=29606639"
}
}
Note that there is a paging result returned as well - this is the URL you will need to query in order to get the next batch of results. It uses the limit parameter and also the offset parameter to ensure that you don't get duplicate results.
In my example, I've given a limit of 10 users per response, but I've managed to get data even when specifying 1000 results. The bigger the limit you provide the longer the request will take to return data.