How can I return with a list of events within a 5km radius? - facebook

I can't seem to find anyway to bring event info from any public events. And I want to pull it over without having previously interacted with the event.
I want this to include events I haven't interacted with.
I tried using these (with GET): https://graph.facebook.com/search?type=event&q=event_name&center=latitude,longitude&distance=5000&access_token=ACCESS_TOKEN
&
https://graph.facebook.com/search?type=event&q=*&distance=5km&fields=id&access_token=ACCESS_TOKEN
But no luck. Just returns with this both times:
{
"id": "https://graph.facebook.com/search"
}
What can I search to get this to work?
My active permissions are:
user_location
user_likes
user_gender
user_age_range
page_events
user_events
read_insights

Related

Get the list of user groups with Facebook API

I'm trying to get a list of the user's Facebook groups.
To do this, I analyze the documentation to understand it (Graph API) :
https://developers.facebook.com/docs/graph-api/reference/v3.2/user/groups
However, when I use this query, I get no results
I've done a lot of research.
And from what I understand, it is no longer possible today to obtain the list of user groups (depeacrated)
However, I do not understand. The documentation page still exists, for version 3.2 ( https://developers.facebook.com/docs/graph-api/reference/v3.2/user/groups) and nothing says that this is no longer possible.
Documentation says :
Returns a list of Groups where the User is a member and the User has granted the app any Group-level permissions for that Group "
My code :
FB.api(
"/" + id + "/groups",
function (response) {
if (response && !response.error) {
console.log(response);
}
}
);
I would like to get a list of all the user's groups, not just the groups where he is an admin.
https://developers.facebook.com/docs/graph-api/reference/user/groups/
admin_only=true
pass this parameter you will get only list of those groups where you are admin.
I managed to get the groups, when askd for groups_access_member_info permission during the facbook-login process, but it asks too much: with this permission app can post in your groups as well and can read former posts. I guess nobody will give you this rights, it seems this feature is over.
Additionally: in my privacy settings i found that the list of my groups are private information (haven't set is explicitly .. at least i dont remember) so it's maybe practically deprecated because of this default setting.

Facebook graph api me/events returns blank

I'm using the Graph API Explorer and have given permissions for user_posts, user_likes & user_events.
me/posts and me/likes return non-empty data, but me/events returns this:
{
"data": [
]
}
I do have ongoing and upcoming events (interested) and they are visible on my Facebook profile.
Any idea what's going wrong? Or is it a Facebook bug?
https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes
Testing of our more robust process starts today and the new process
should resume in a few weeks, but apps currently accessing Events and
Groups APIs will lose access today.
This may also be interesting for you: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#events-4-4

Facebook graph API 'friends' request now only returning 25 friends per page? What's going on?

My application(game) has been running on Facebook for some time. I start by requesting a friends list via the graph API call: my-uid/friends
asking for user name and profile pic.
Normally I get back a list of all my friends up to a few thousand, until it starts putting friends on to the next page. Which is nice as most of my users get friends in 1 call.
Suddenly however, and with no changes to the app. about 40 minutes ago (18:40 Tuesday (PDT) - 2nd May 2012) I started getting responses with only 25 friends per 'page'!
I can still get my whole friends list using multiple calls, but the game is not currently set up to do that properly. Can anyone tell me why the sudden change? Anyone else seen similar problems and how do I get the list to give me up to 5000 friends per page like it used to.
Reproducible using the Graph API Explorer
I don't know what else to tell you; perhaps the default number returned has changed, but when I try, a call to /me/friends?limit=5000 returns the full list for me (but my friends list is >500 and < 1000 , so maybe it cuts off somewhere along the way)
(Side note: the average number of friends has been found to be ~190 so presumably most users will have less than 500 anyway, and having to page above 500 would be an edge case
In SDK 4.7 you need to pass in a bundle with the number of friends you want to return, I have set it to 5000 as this is the maximum number of friends you can have on Facebook.
You also need to set up your app as a game in the facebook dev console and use invitable friends to get a full friends list
Create your bundle
Bundle bundle = new Bundle();
Add params to your bundle
bundle.putInt("limit", 5000);
Then pass it in to your GraphRequest
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/invitable_friends",
bundle,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
//Do something with the response
}
}
).executeAsync();
It seems that facebook changed its limit to 25 results in other api calls too (feed, posts, friends, etc), if you request friends without parameters the JSON response shows the following:
"paging": {
"next": "https://graph.facebook.com/USER_ID/friends?format=json&limit=25&offset=25&__after_id=LAST_ID"
}
Anyway you could/should always set limit & offset parameters to prevent this kind of things, limit = 0 will return all your friends list.
https://graph.facebook.com/USER_ID/friends?limit=0
If you are only requesting friends from a normal user the maximum number allowed is 5,000 so the limit should could be either 0 or 5,000 if you are requesting info from a facebook page or other kind of api calls like posts or feed this limit could increase or decrease.
(Update) Facebook fixed this bug so setting limit to 0 returns 0 friends, you should set a positive limit, thanks Dinuz
I think the best thing you can do is to add limit=5000 parameter as Igy says.
However I posted a bug report since this change wasn't noticed or described in the document.
The number of results returned from the /v2.2/me/friends endpoint now defaults to 25.
Friend list now only returns friends who also use your app: The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
See Facebook changes
Facebook API change log
If you are using GraphRequest() (e.g. in React Native), you can put it directly in the string field, like so :
new GraphRequest(
'/me',
{
accessToken,
parameters: {
fields: {
string: 'id,email,first_name,last_name,friends.limit(5000)'
}
}
...

User object returned from Graph API intermittently contains empty array for permissions data

I'm running into a situation where requesting a list of permissions that a user has granted to a canvas application intermittently returns an empty array.
The graph request would look something like this:
https://graph.facebook.com/[uid]?access_token=[token]&fields=permissions
Typically, a normal response would look something like this:
"permissions": {
"data": [
{
"installed": 1,
"email": 1,
"bookmarked": 1,
"publish_actions": 1
}
]
}
Occasionally though the response looks like this:
"permissions": {
"data": [
]
}
The code equates this situation to the user having not granted any permissions and restarts the auth flow. The problem appears to be intermittent, because the users eventually make their way into the application and if I manually retry some of the failed requests I find in logs the permissions are returned as expected.
Looking at the User API docs (http://developers.facebook.com/docs/reference/api/user/), it looks like permissions that are not granted are excluded. It's not clear from the documentation what happens when no permissions are granted. One would assume an empty map, which would render a response something like:
"data": [
{
}
]
However, even if the response is an empty array, the point in the code where this request is made should not be reachable without accepting a least some permissions.
This leaves me with a few questions that I'm hoping someone with relevant knowledge can answer:
Are there any circumstances under which the permissions granted by the user to the application are not available via the Graph API?
Are there any circumstances under which a canvas application can be authorized by the user without granting any permissions? (cancelling the auth dialog results in a request with additional query string params, which is handled differently)
Are there any circumstances under which a user can revoke initially-granted permissions without de-authorizing the application?
Edit:
Based on the discussion below I would like to clarify that my app requires the email permission, which does not appear to be revocable. The app has always required the email permission, so there shouldn't be a case of an older install without that permission.
Nope, not to my knowledge.
That situation is called basic permissions, where no additional permissions are specified in the scope parameter during login
Yes, the app user can revoke certain permissions. Go to (http://www.facebook.com/settings?tab=applications) and click edit on one of the apps (for example Groupon or Music or YouTube) and you can see there's certain permissions that can be removed by the user at any time. So it is good your app reads the permissions it still has available to it. It might save you some wasted graph calls to objects/actions you're no longer able to get.

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.