Facebook graph API returns false for existing and public event - facebook

There is a public Facebook event, for example: http://www.facebook.com/events/197276753679964/
I want to get information about this event using Facebook graph API.
I'm using this query url: http://graph.facebook.com/197276753679964
Facebook returns "false", but event is existing and public, so what's the problem?
There are a few more events with this annoying behaviour, but other ~95% I can read succesfully using FB graph API.

If the event is owned by a group or page which is restricted demographically, you can only access that even with the access token of a user who can see the event / page.
(this appears to be the case with the example in this question)
In general (one current bug excepted), 'false' means a privacy check failed

Related

Facebook Api search users by name returning empty data

I used this url with access token https://graph.facebook.com/search?q=Marcus&type=user&access_token= and it returns empty data data []
Settings https://i.imgur.com/6hEiO5y.png
I was trying to get a list of users with their name using javascript. Is it possible ?
as mentioned in the comments here is the official Facebook note, that you cannot search for type = user anymore:
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
The /search endpoint for pages, videos, groups and events has been disabled by facebook after the cambridge analytica scandal.
Faceboook Changelog:
You can no longer use the /search endpoint with the following object types:
event
group
page
user

Facebook graph API {post-id}/likes returns empty data

This request returns an empty array: graph.facebook.com/773227196065108/likes, but this request returns a normal array: graph.facebook.com/576234822476425/likes.
First post - post from user, second post - post from page.
How do I get a normal result in the first case?
http://graph.facebook.com/773227196065108 returns
{
error: {
message: "An access token is required to request this resource.",
type: "OAuthException",
code: 104
}
}
since its a user post and probably not public, you will have to access it using a proper access token on behalf of the user . also the number of likes obtained via graph api is dependant on the the privacy settings of people who liked the post .
the second post is one from a page and is public, so its directly accessible for you .
773227196065108 is a user whereas 576234822476425 is a page. Public page posts can be inspected in the API, public user posts have certain restrictions applied to them such as, the queried user must be using the application as well. If the queried user isn't using the querying application the response will be empty.
In addition /me/likes/773227196065108 will not work as /me/likes are only for pages not posts.

Creating "SECRET" events through Facebook's graph api as a Facebook app

I was able to create facebook events through graph api from my facebook app with this POST request:
POST https://graph.facebook.com/<MY_APP_ID>/events?
start_time=2013-12-21T19%3A30%3A00
&end_time=2013-1221T20%3A30%3A00
&name=test+event
&access_token=<MY_APP_ACCESS_TOKEN>
The response was a JSON, with the id of the newly created event.
After this i tried to create an other event with 'SECRET' privacy:
POST https://graph.facebook.com/<MY_APP_ID>/events?
start_time=2013-12-21T19%3A30%3A00
&end_time=2013-1221T20%3A30%3A00
&name=test+secret+event
&privacy_type=SECRET
&access_token=<MY_APP_ACCESS_TOKEN>
The response here was also a JSON with the id of the created event.
After that I tried to list the events of my app:
GET https://graph.facebook.com/<MY_APP_ID>/events/?access_token=<MY_APP_ACCESS_TOKEN>
In the response JSON, I can see only one, the not-secret event. The secret one is missing.
After this, i tried to get the details of the events one-by-one:
GET https://graph.facebook.com/<EVENT_ID>/?access_token=<MY_APP_ACCESS_TOKEN>
In case of using the id of the non-secret event, the response contains all the details of that event, but when I'm using the id of the secret-event, it responds with an error msg:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
Why am I not able to create SECRET (invite only) events with my app?
Events can be created for three object types via the Graph API: Users, Pages and Applications, according to the Graph API Events page:
The User, Page, and Application objects have an events connection.
However, the Graph API Event page then only supplies links to the User and Page sections on how to create an Event (See Graph API Event page, Section Creating Events). There's no further reference to Application events and The Application section doesn't mention an Events connection.
Out of the two linked-to Event types, creating an event with the privacy_type parameter is only supported for Users, not Pages:
Supported parameters for creating a User Event
name, start_time, end_time, description, location, location_id, privacy_type
Source: User Graph API details on Facebook Developers
Supported parameters for Creating Page Event:
name, start_time, end_time, description, location, location_id
Source: Page Graph API details on Facebook Developers
So my guess would be that Application follows the Page Event connection parameters but that this isn't properly documented.
If you created it as SECRET, you won't be able to retrieve that event using the app access token, because your app is not a user, and cannot see the event.
It's only visible to the user who created it and the other attendees - the user's access token should return the event, because the user access token acts with the same permissions as the user, and if they're marked as attending the event, they can see it
I guess, you shoud use one of these methods:
GET /EVENT_ID/invited/USER_ID
GET /EVENT_ID/attending/USER_ID
GET /EVENT_ID/maybe/USER_ID
GET /EVENT_ID/noreply/USER_ID
GET /EVENT_ID/declined/USER_ID
Or check out this:
http://developers.facebook.com/docs/reference/api/event/

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.

retrieve events where uid is the creator and application id is the admin - Facebook API

I would like to know if there is a Facebook API call to retrieve the events (eids) for all the events a user has created using my facebook connect application.
The events are created using the following REST api call:
https://api.facebook.com/method/events.create?event_info=' . $e_i . '&access_token=' . $cookie['access_token']
$e_i is the event info array where the 'host' value is set to 'Me' as follows
$event_info['host'] = 'Me';
On Facebook events under the "Created by:" section it lists "My user name,Application Name", I presume this is because I am the creator and the application is the admin as stated in the REST api documentation http://developers.facebook.com/docs/reference/rest/events.create/
Unfortunately I cannot seem to find out how (neither REST nor GPRAPH API) to return a list of events where I am the creator and the application is the admin as in the above scenario. If this is possible I would really appreciate some assistance with how it is done.
So far I have tried:
REST API events.get using uid=application_id. This only returns events created by the application not those including the user who created them
GRAPH API https://graph.facebook.com/me/events?fields=owner&access_token=... this returns all the events for 'me' but not where the application is also the admin.
It seems strange that there's no reference to the linkage between the event creator and the event admin through the API but in Facebook it is able to pull both and display them on the event details.
If you're using the Graph API try calling $facebook->api('/App ID/events') which should return all events managed by the application (http://developers.facebook.com/docs/reference/api/application/).
Later on you can check the creator's ID and compare it with the User ID.