Empty response to API call to Facebook Graph - facebook

I have been hammering away at this problem for the last day. I really hope someone can help me out. I would be very grateful.
What I am trying to do is fetch event data from a Facebook Page. I looked over the documentation, which says this about reading Pages data:
Reading
A Facebook page
Permissions
For pages that are published, you need:
An app or user access token to view fields from fully public pages.
So what I did was I obtained an app access token via:
GET https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
which then returned
access_token=MY_APP_ID|MY_APP_ACCESS_TOKEN
After this I followed the documentation and made the following call
https://graph.facebook.com/v2.4/129511477069092/events?fields=id,cover,name,venue,description&access_token=MY_APP_ID|MY_APP_ACCESS_TOKEN
This returned:
{
"data": [
]
}
So after some fiddling around I was able to make the call by switching to version V2.2 and by creating an access key with Facebook API Graph explorer tool(no permissions granted).
GET https://graph.facebook.com/v2.2/129511477069092/events?
fields=id,cover,name,venue,description&
access_token=ACCESS_TOKEN_FROM_FACEBOOK_API_EXPLORER_TOOL
The page I am trying to retrieve data from is public and so are the events, so I can't figure out what is going on. I know I am super close since I am able to retrieve the data with the token provided by the Facebook API Graph Explorer Tool. The thing with using this token is that it only last a few hours and I need something that is going to last longer such as an app access token. I have done some research on Stackoverflow and found similar questions, but none of them solve my problem. Any help will be appreciated to the max! Thanks.

Looks like a bug of v2.4 to me. It works with v2.3 if you remove the deprecated venue field:
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=129511477069092%2Fevents%3Ffields%3Did%2Ccover%2Cname%2Cdescription&version=v2.3
If the version is changed to v2.4, it returns an empty result.
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=129511477069092%2Fevents%3Ffields%3Did%2Ccover%2Cname%2Cdescription&version=v2.4
There's no documentation about this in the changelog at
https://developers.facebook.com/docs/apps/changelog#v2_4
so I guess it's a bug. There's already a bug report at
https://developers.facebook.com/bugs/443054055873667/
with status assigned. If you have an app that supports v2.3, I'd suggest you prefix your request like this:
GET /v2.3/129511477069092/events?fields=id,cover,name,description

Related

Is fb graph user search api not working anymore?

https://graph.facebook.com/search?q=sharma&fields=name&type=user&access_token=
I was this URL along with access token and it was giving me user name list that i was using in my project. Only names are my requirement but when today i started to use it i am not getting any data nor any error.
Its only returning this
{
"data": [
]
}
Recently a month ago it was working for me.
Can anyone tell me if they have the same issue or if something has changed?
Is there any other was of getting users name mainly first + last name from fb?
I have found answer of my question which is Fb is no more giving user results for graph search api.
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Search API
You can no longer use the /search endpoint with the following object types:
event
group
page
user
I dont know whether its a permanent revoke or temporary but it has something to do with Cambridge analytica data leak issue
https://www.google.co.in/search?biw=1360&bih=662&tbm=nws&ei=-iTXWrrkCYrxvgTTy5GgCw&q=cambridge+analytica+data+leak&oq=cambridge+analytica+data+leak
I hope it will help others to find out why their API is not working anymore.

Searching public profiles using Facebook Graph API

I am looking to search Facebook public profiles using the Graph API with parameters like name, location and age. To accomplish this I created a Facebook app to get an app ID but I am unsure as to how to proceed to make the query to the API.
To try it out I tried using the explorer (https://developers.facebook.com/tools/explorer/) but I am unable to get any results that does not contain "me". I made sure to get a access token and enter a query like the following:
search?q=tobias&type=user&fields=id,name
The only reply is:
{
"data": [
]
}
I feel like I am missing something but I have been unable to figure out what, please advice.
The search endpoint is broken since 2018-04-04 for certain search types, including pages and users.
Search API
You can no longer use the /search endpoint with the following object types:
event
group
page
user
See
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Due to what has recently been in the news, searching for users has been deprecated, and is not supported through Facebook APIs.

An unknown error has occurred on Graph Facebook

I tried to get Data from Facebook Page with the graph of Facebook but I have a problem.
When I try to go on link like:
https://graph.facebook.com/ID-PAGE?access_token=MY_ACCESS_TOKEN
I always do this to have the Data from a Page but since today I have the error Message: "An unknown error has occurred".
Thanks for help.
EDIT:
The bug is fixed : https://developers.facebook.com/bugs/486654544831076/?search_id
Have a look at my answer at
How to get user email and birthday from Facebook API Version v2.4
You have to specify each field you want to query now with v2.4. If you want to explicitly use v2.3, you need to prepend your calls by /v2.3 like this:
/v2.3/{page_id}?access_token=MY_ACCESS_TOKEN
Seems like there's currently a bug regarding requests made with app access tokens instead of user access tokens:
https://developers.facebook.com/bugs/486654544831076/
At this moment, I pretty much figured out what is happening, and it looks like a bug in the Facebook API.
For v2.3 and lower:
The /PAGE-ID call will return an Unknown server error when you don't pass ?fields=username (for example). If you do pass the fields option, it will work. You can get it out of the docs.
For v2.4:
This will work, but you will miss a lot of data, so you'll also have to pass the fields options. But if you don't pass that, this version will give you back only the most basic of details. This is as described in the version release: https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
So the solution for now, would be to add the ?fields= everywhere you need, or to wait for Facebook to maybe ever solve it.
(And while you're at it, you might as well upgrade to v2.4 ;-)

Facebook graph api - Unsupported get request

I'm creating a custom module in Drupal, that for part of its functionality must fetch posts from a business page. So for simplicity, I'm using fbapp module as a dependency (drupal.org/project/fbapp), so that I can use it's authentication and request functions (fbapp_app_authenticate() and fbapp_graph_request()) without having to worry about the constant facebook graph updates making my own code obsolete.
I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"
Here's the queries and responses my code produces:
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials
array(1) {
["access_token"]=>
string(43) "<redacted>|<redacted>"
}
graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"
string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"
Can anyone verify a correct way to query a Facebook page programmatically, perhaps there's a setting in the page I'm querying that I need to set (although I can't find anything)?
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):
See
https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms
It looks like everything you have done is correct. The response you got can be (i am not sure) because you got your clients pageid wrong.

facebook graph api returns empty data array

I wanted to get the events for a closed group (which has tons of events) via the facebook graph api, but I only got
{
"data": [
]
}
in the Graph API Explorer even though I was using an auth token with user_events enabled. Just to be sure, I enabled every single permission for the token but got the same result.
what am I doing wrong?
I think I just found the answer to my problem; there was nothing wrong!
What I thought were events coming up were actually events that happened in the past, shown in the group/events page; I guess those aren`t aren't accessible.
I think I'll settle with using FQL as offered as a solution in this question.