Facebook Graph Search Error while searching "Event" - facebook

This is embarrassing, but I am at my wits end. While performing a very simple search for "Events" using fb Graph Search, I get the following error:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}}
This is the code I execute:
https://graph.facebook.com/search?q=conference&type=event&limit=1&access_token=XXXXXXXXXX|XXXXXXXXXX
It works JUST FINE for any other type of search - with the same access token for example:
https://graph.facebook.com/search?q=conference&type=place&limit=1&access_token=XXXXXXXXXX|XXXXXXXXXX
I get the following result:
{
"data": [
{
"category": "Local business",
"category_list": [
{
"id": "164243073639257",
"name": "Hotel"
}
],
"location": {
"street": "Langelaan 3",
"city": "Noordwijk",
"state": "",
"country": "Netherlands",
"zip": "2211XT",
"latitude": 52.251963727407,
"longitude": 4.4722281054509
},
"name": "NH Conference Centre Leeuwenhorst",
"id": "165032770219308"
}
],
"paging": {
"next": "https://graph.facebook.com/search?limit=1&type=place&access_token=XXXXXXXX|XXXXXXXXX&offset=1&__after_id=165032770219308"
}
}
At this point, I am out of ideas.

Facebook recently changed things in their API, Search was one of those things. You can only do this kind of search on Places and Pages now. To search events, you need an app access token. See this blog post: https://developers.facebook.com/blog/post/2013/04/03/platform-updates--operation-developer-love/

Fixed! I am now able to search for events by using an App Token generated using the new api. Thank everyone for your help

Related

Unsupported get request. Object with ID '{USER_ID}' does not exist, cannot be loaded due to missing permissions, or does not support this operation

I am getting this from Facebook webhook. I am trying to get the sender's name and profile picture.
<pre>
{
"object": "page",
"entry": [
{
"id": "172916740162087",
"time": 1609667491,
"changes": [
{
"value": {
"from": {
"id": "2529118547136023",
"name": "Md Abid Hasan Nayem"
},
"post": {
"status_type": "added_photos",
"is_published": true,
"updated_time": "2021-01-03T09:51:29+0000",
"permalink_url": "https://www.facebook.com/CodeWareLTD/posts/851154192338335",
"promotion_status": "inactive",
"id": "172916740162087_851154192338335"
},
"message": "Happy new year",
"post_id": "172916740162087_851154192338335",
"comment_id": "851154192338335_853191445467943",
"created_time": 1609667489,
"item": "comment",
"parent_id": "172916740162087_851154192338335",
"verb": "add"
},
"field": "feed"
}
]
}
]
}
</pre>
When I am sending request with the user id /{USER_ID}?access_token=token then it's returning this error.
Whereas I have all the required permissions approved.
<pre>
{
"error": {
"message": "(#3) Application does not have the capability to make this API call.",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "ABtpgYvcMuaA_jQcW8Fdi3M"
}
}
</pre>
I opened a bug report, but they told me it's ok as per the current Facebook system design. But
still, I'm unable to get the user's first name, last name, and profile picture.
Bug Report Link: https://developers.facebook.com/support/bugs/887826828623849/.
Please, help me to get the exact API to get the sender's name & profile picture.
my currently successfully reviewed permissions are:
email,
pages_manage_metadata,
pages_read_engagement,
pages_show_list,
pages_messaging,
pages_read_user_content,
public_profile,
pages_manage_engagement,
pages_manage_posts

How can I get all photos in one post in a page using Graph API?

For example this graph
https://graph.facebook.com/audi/posts?access_token=[ACCESS TOKEN]&fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&since=2016-10-14T17:54:17+0000&limit=1
will give you this result(after replace ACCESS TOKEN with your access token ) :
{
"data": [
{
"id": "96585976469_10153772437221470",
"message": "Take a night tour of Capitol Hill with the #AudiRS7. #AudiDuel",
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/14680669_10153772435521470_6025374941796908984_n.jpg?oh=3654e74f79914c9bb0fa596ce8434c46&oe=589E82B4",
"link": "https://www.facebook.com/audi/photos/a.101113351469.101662.96585976469/10153772435521470/?type=3",
"name": "Photos from Audi USA's post",
"type": "photo",
"icon": "https://www.facebook.com/images/icons/photo.gif",
"created_time": "2016-10-14T17:54:17+0000",
"from": {
"name": "Audi USA",
"id": "96585976469"
},
"object_id": "10153772435521470"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=1476467657&access_token=[ACCESS TOKEN]&__paging_token=[ACCESS TOKEN]&__previous=1",
"next": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=2016-10-14T17\u00253A54\u00253A17+0000&access_token=[ACCESS TOKEN]&until=1476467657&__paging_token=[ACCESS TOKEN]"
}
}
and this is the link of the post
https://www.facebook.com/audi/posts/10153772437221470
it gave me just the first one photo but I need all photos in this post
attachments is the field you are looking for.
(Seems not officially documented, perhaps because those aggregate posts are special. But Graph API Explorer suggests it as one of the available fields.)

Getting facebook place id from instagram place

I know from the documentation of the instagram API that instagram has facebook locations mapped so you can search and get the location detail from instagram via facebook place id i.e.
https://api.instagram.com/v1/locations/search?facebook_places_id=273471170716&access_token=[ACCESS-TOKEN]
As you can see I am retreiving the location detail via facebook place id.
But in my scenario, what I want is to get facebook place id using instagram id from the instagram location detail. Below is what I mean:
I have got the instagram location id and can get the detail of the place using the following:
https://api.instagram.com/v1/locations/2862169?access_token=[ACCESS-TOKEN]
But the above call only returns the location name and geographic co-ordinates. Whereas I want the Facebook place id of the location as well. Is there any way for me to get the facebook place id from the instagram as well?
I have checked their documentation on Location endpoints (https://instagram.com/developer/endpoints/locations/) and wasn't able to find any relevant information.
The reason why I want that is, I need to get the location detail such as category etc as well which instagram API doesn't provide, so I plan on using this retrieved facebook place id on facebook graph API to retrieve this additional location details.
I think you can only use the Facebook Graph API search for this. Therefore, you can use the output from the Instagram API for latitude, longitude and name to construct a Graph API call which returns you a list of matching Facebook Place Pages.
If the Instagram location id is 788029 for example, the API will return the following JSON:
{
"id": "788029",
"latitude": 48.858844300000001,
"longitude": 2.2943506,
"name": "Eiffel Tower, Paris"
}
So, if you take this result and use the data to construct a Facebook Graph API search url, it will result in something like this:
https://graph.facebook.com/search?q=Eiffel%20Tower,%20Paris&type=place&center=48.858844300000001,2.2943506&distance=100&limit=3&access_token={app_access_token}
You can choose the distance as well as the limit as you desire. If you set limit=1 you will only receive the place which Facebook deems to be the best match. Replace {app_access_token} with an actual App Access Token.
The Facebook response will be something like
{
"data": [
{
"category": "Local business",
"category_list": [
{
"id": "276651312419490",
"name": "Monument"
}
],
"location": {
"street": "",
"city": "Paris",
"state": "",
"country": "France",
"zip": "75007",
"latitude": 48.858385562198,
"longitude": 2.2944861654879,
"located_in": "141184112585566"
},
"name": "Level 2 Eiffel Tower, Paris",
"id": "380503552017025"
},
{
"category": "Local business",
"category_list": [
{
"id": "186825111351005",
"name": "Tourist Attraction"
}
],
"location": {
"street": "",
"city": "Paris",
"state": "",
"country": "France",
"zip": "",
"latitude": 48.858205346341,
"longitude": 2.2944900587791
},
"name": "Eiffel Tower Sommett, Paris, France",
"id": "1458706024363987"
},
{
"category": "Restaurant/cafe",
"category_list": [
{
"id": "168976549819329",
"name": "French Restaurant"
}
],
"location": {
"street": "",
"city": "Paris",
"state": "",
"country": "France",
"zip": "75007",
"latitude": 48.858532957713,
"longitude": 2.2941094631632,
"located_in": "141184112585566"
},
"name": "58 Tour Eiffel (officiel)",
"id": "148894855169991"
}
],
"paging": {
"next": "https://graph.facebook.com/v2.2/search?limit=3&type=place&q=Eiffel Tower, Paris&center=48.858844300000001,2.2943506&distance=100&offset=3&__after_id=enc_AdCYS3bVKOc29JFMrqlsouSZCvBxUTYZC7nHvqDHKAiBNrOs2ehUIaOsJ2wL9TxF9KOfgGmqEPOaLwotDM4pIUqyFf"
}
}
See
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
https://instagram.com/developer/endpoints/locations/

Facebook Graph API: Getting latitude/longitude of a Checkin via Fields API (optimized calling)

I'd like to know whether there is a way to directly get the latitude/longitude fields via the Facebook Graph API.
The background is that I want to reduce the amount of data which is returned by the Graph API by getting rid of fields which are not of interest for my application.
I know there's something like this working in the Graph API Explorer:
me/?fields=id,checkins.fields(id,place.fields(id,location),created_time)
It returns the following:
{
"id": "12345",
"checkins": {
"data": [
{
"id": "101511234546244",
"place": {
"id": "170048419682121",
"location": {
"street": "",
"city": "Frankfurt",
"state": "",
"country": "Germany",
"zip": "",
"latitude": 50.108641831527,
"longitude": 8.6654729704433
}
},
"created_time": "2012-11-08T08:30:48+0000"
}
]
}
As I don't need the address parts of the location, I'd really like to get rid of them as well. If I try this the follwoing way, it doesn't work:
me?fields=id,checkins.fields(id,place.fields(id,location.fields(latitude,longitude)),created_time)
The result is
{
"id": "12345",
"checkins": {
"data": [
{
"id": "101511234546244",
"place": null,
"created_time": "2012-11-08T08:30:48+0000"
}
]
}
Did somebody have success in doing something similar? If so, I'd be great if you could let me know. Thanks!
According to the API documentation and the Graph API explorer, Subfields are not supported by location so you are unable to extract just latitude and longitude from the location object.

How do you retrieve the "Place" field of a Facebook Graph Post object?

I am trying to retrieve the "Place" field of a Facebook Graph Post object from a Facebook friend. After obtaining an access token with the friends_status and read_stream permissions, I request from the Graph API like so:
http://graph.facebook.com/[user_id]_[post_id]
What is returned are some of the fields described in the Graph API docs for Post:
{
"id": "1164358582_2458311174854",
"from": {
"name": "Joe Blo",
"id": "1164358582"
},
"message": "Is pretty bummed today",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
},
{
"name": "Like",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
}
],
"type": "status",
"application": {
"name": "Facebook for Android",
"id": "350685531721"
},
"created_time": "2011-11-20T03:23:04+0000",
"updated_time": "2011-11-20T12:12:49+0000",
"comments": {
"data": [
{
"id": "1164358582_2458311174852_2962531",
"from": {
"name": "Sue Candy",
"id": "1056617421"
},
"message": "OMG I'm so sorry!!!",
"created_time": "2011-11-20T03:25:06+0000"
}
],
"count": 1
}
}
This is all fine and dandy, except for the fact that when I see this Post within my Facebook stream, it also shows a location accompanying the post:
9 hours ago near El Reno, OK
I expected the El Reno, OK Place object returned as a field within this Post, but I don't see it.
In the Facebook Graph API Explorer, I've tried enabling almost every permission and I am not seeing any difference in the response (no "Place" field returned). Am I going about this incorrectly?
Not 100% sure but I think you can only get the "place" info if it is of type "checkin". I totally get where you are coming from, I wondered about that myself.
https://developers.facebook.com/tools/
Try the Graph API Explorer Tool if you haven't already looked at it.