I am using Facebook Graph API to retrive page insights information. My issue is that I can't get the ones older than 3 months. For example if I use /insights/page_fan_adds/day?since=2013-01-20&until=2013-04-23 is all working fine but if I use /insights/page_fan_adds/day?since=2013-01-19&until=2013-04-23 (one day before the previous since) I receive the following error:
{
"error": {
"message": "Unsupported operation",
"type": "FacebookApiException",
"code": 100
}
}
This means is not possible to get older information from the facebook page insights or I have to do something else like for example use some permissions or use other syntax?
Facebook will not allow more than 89 days, but you can adjust the since/until fields to get data older than 89 days.
Facebook will return up to 93 days of insights data. You can verify this for yourself by experimenting with the since and until fields.
If you need more than 93 days, as suggested in another answer, you'll have to modify the since and until fields to get different "windows" of data. Note that in the data returned by Facebook, paging URLs are included for your convenience. You can use them instead of reconstructing the URLs if you so desire.
Related
I have a project where I have to search Facebook for all people at a
certain location and then apply further filters to the data. My problem and question is:
How do I get the initial data, using Graph API?
I know that it is possible, using the search field in Facebook itself. Just typing "All people living in ???" returns a list of people.
I couldn't find such functionality in the Graph-API of Facebook. Here is what I tried:
I modified some parameters of the standard search request
search?type=user¢er=52.946758,-1.172882&distance=1000
search?type=user¢er=Nottingham&distance=1000
and here is what I got:
{
"error": {
"message": "No node specified",
"type": "GraphMethodException",
"code": 100
}
}
Using a similar query with location instead of center
search?type=user&location=Nottingham&distance=1000
search?type=user&location=52.946758,-1.172882&distance=1000
search?type=user&q=&location=Nottingham
and only got a confusing error that the location I wrote is wrong
{
"error": {
"message": "(#160) Invalid coordinates. Coordinates must contain at least latitude and longitude.",
"type": "OAuthException",
"code": 160
}
}
Then searching for a user with the coordinates as query parameter returned an empty result.
search?type=user&q=52.946758,-1.172882&distance=1000
{"data": []}
Then I tried to search for a correct location to pass to the location parameter of the query
search?type=location&q=52.946758,-1.172882
and I only got a deprecation error
{
"error": {
"message": "(#12) location search is deprecated for versions v2.0 and higher",
"type": "OAuthException",
"code": 12
}
}
I don't know how to get to this. If someone could tell me, how to get this information, it would help
me a lot, since I don't know what to try next.
I have found this question similar to my problem, but the accepted answer isn't really answering the question
Facebook Search API - List all users based on location?
You can either search for a location OR search for a user, but you can definitely not search for "all users in an area". The Graph search on Facebook can handle a lot more things that you will never be able to get with the API. Think about privacy, i would not want any app to know if i am nearby, without even authorizing the App ;)
Facebook docs: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
For getting the locatoin where the user is living, you need to check out the user reference: https://developers.facebook.com/docs/graph-api/reference/v2.2/user
There is a "location" field in there, you need to authorize a user with the "user_location" permission to get that information. It is not possible to get that information from any user. Just because you can see data on Facebook and it is public does not mean you can access it with an App, for privacy reasons this is only possible by authorizing the user.
Scraping without an App is not allowed btw, check out the scraping terms: https://www.facebook.com/apps/site_scraping_tos_terms.php
I tried this -> "firstname lastname location" and it works perfect.
For example -> "Sameeksha kumari australia"
The query looks like this
https://graph.facebook.com/v2.5/search?fields=id,name,picture.type(normal),location&limit=500&q=sameeksha kumari melbourne&type=user&access_token=token
I've read so many posts regarding this issue, nevertheless no solution was found.
I'm using the graph explorer with ALL permissions selected (on both "User Data Permissions" and "Extended Permissions")
Trying to query a group feed via: /{group-id}/feed
And some posts are missing.
I saw that someone somewhere wrote that FQL will probably overcome this limitation - but Facebook announced that they are going to suppress FQL.
----------------[Try it Yourself]---------------------
Join the group "IT Security" (This is just an example). You can find the group with facebook.com/6340489103
find a post by "Gabor Nagy". Tip: after joining the group, you can access the post directly via "facebook.com/10152587882559104".
Go to the graph explorer (link above)
type /10152587882559104 which is /{post_id}
did you receive "code: 100"?
{
"error": {
"message": "Unsupported post request.",
"type": "GraphMethodException",
"code": 100
}
}
try other posts and see that it works fine
How come I can access this post directly but not through the graph api?
SOLVED!!!! (well, more or less)
I've approached some of the people who posted the posts that cannot be accessed via Graph API.
After some debugging we have found the source.
They all turnd off the Facebook Platform option: https://www.facebook.com/about/privacy/your-info-on-other#friendsapps
This stops apps from accessing their data.
It doesn't really helps me with my project, but at-least I feel better. ;)
Enjoy
I'm trying to get facebook feeds from multiple ids using the Facebook Graph API on ios6. I don't think this will work though, as I'm trying to test it in the developers.facebook.com graph explorer tool, and it doesn't work. Here's what I'm doing:
in the graph explorer (where "my id" is my actual numerical id, etc.):
/id="my id"/feed --> this works
/ids="my id","my friend's id"/feed --> this does not work, I get the error
message": "(#803) Some of the aliases you requested do not exist:
ids=,",
"type": "OAuthException",
"code": 803
Do I need to get the feed for all my friends and then filter by id? That seems wasteful.
It appears that you're formatting the query incorrectly
ids is a parameter to the query, not part of the path (which /feed is)
/feed?ids=X,Y,Z should work
I am trying to get the page insights.. the only metrics being shown are page_fans_country and page_storytellers_by_country. For rest of the metrics the following output is coming
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/22754734656/insights/page_fan_adds?since=1364712822&until=1364972022",
"next": "https://graph.facebook.com/22754734656/insights/page_fan_adds?since=1365231222&until=1365490422"
}
}
Even if there is no addition in the no of fans '0' value should come as the output.. I am stuck.. Please help
Thanks
I know that it won't answer the question correctly but...
Those insights are public so you just need an App, Page or User access token to request them.
However, Facebook is struggling to have its insights working properly. They use to be 3 days delay, now it's 5 days sometime. And now for few days it's not returning anything if you don't specify the date range. ie:
/cocacola/insights
is not returning anything but sometime it is (latest insights)
To fix it few weeks ago I've read that specifying the metric would do it, and yes:
/cocacola/insights/page_fans_country,page_storytellers_by_country
But now it's not anymore. The only thing working is if you specified since and until
ie: /cocacola/insights?since=1368503760&until=1368662399
But it's really a pain in the *** because you need to know which date is the latest available before to query your insights.
Facebook API sucks!
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)'
}
}
...