Facebook FQL posts limit issue - facebook

Currently i am using following FQL query :-
https://api.facebook.com/method/fql.query?query=select post_id,likes FROM stream WHERE source_id=XXXXXXXX LIMIT 0,10000&access_token=XXXXXXXXXXXXX&format=json
I have two Facebook Accounts / pages & able to download data using above API. Able to retrieve posts & post likes count.
But, from last three days, for one Facebook account above FQL query is not working. it is returning message :- "error": "Request failed" . For other account it is working fine.
For each facebook Account / pages i have generated separate Access Tokens.
But, if i update limit from : -
Limit 0,50
Limit 50,100
then it is working & returning posts from page but not returning all post which i have previously getting from Limit 0,10000
Please help me, if any one have idea about this issue ?
Thanks

Facebook will cancel queries which take too long or too many resources to execute. In general, I would never use LIMITs which are that high. There's a high probability that they will fail, and you can't really incfuence the query execution "load" other than setting the LIMIT to a reasonable number (which means implementing a paging mechanism).

Related

How to get Facebook page total likes number with the new Graph API (v2.4)

So recently there was a update to the Facebook Graph API and now pretty much everything requires a access_token to retrieve any type of data.
Previously you could get the number of page likes by accessing the graph like so:
http://graph.facebook.com/{page-name}
But now if you try it says you need to have a access token because of a recent update to the API. Now the issue i am having is i cant access the likes even with an access token this is the response i am getting:
Request
http://graph.facebook.com/{page-name}/?access_token={access_token}
Response
array(2) {
["name"] "Page Name"
["id"] "Page Id"
}
Now at first i thought the access token wasn't being generated with the correct scopes but i am 99% sure you only need read_stream to pull that type of data.
Second thought is that they have removed the ability to acces likes of any page and you need a page token to receive that type of data or finally i am missing something incredibly small here and its still achievable?
So my question is can you still get the number of likes of any page using the Facebook Graph API and if the answer is yes how do you do it?
any help appreciated
This can help you! Just add ?fields=likes after the page name/id. You can use any access token for fetching data!
graph.facebook.com/{page_name}?fields=likes&access_token={token}
The Graph API v2.4 reduces the number of fields in default responses.
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance: To help improve performance on mobile network connections, we've reduced the number of fields that the API returns by default. You should now use the ?fields=field1,field2 syntax to declare all the fields you want the API to return.
If you do ?fields=likes it should show up.
You can do like this:
https://graph.facebook.com/v2.4/{page_id}/fields=likes

In Facebook Graph API - Is LIMIT parameter realy functional?

I'm trying to collect all the posts of my company page with this kind of query
https://graph.facebook.com/v2.2//feed?limit=250&fields=id,type,status_type,comments{id},likes{id},shares
Problem is that I'm not collecting all posts.
I will have a better result with limit=20 and some time with limit=100
Most of the pages (from the pagination mechanism point of view) will not have 100 items.
I know some posts may not be exposed because of privacy settings.
My issue is that a call with limit=20 is not returning once going through pagination the same amount of data as limit=250.
How could it be?
How providers of Facebook Analytics can garanty the quality of data they collect ?
The Facebook graph api only allow the max of 100 items per request, despite you specify more than that.
Afaik the limit parameter is indeed buggy. But 250 would be a very high value, there is a max value for the parameter too - i assume it depends on the API call how high it is, could be fixed too.
Better donĀ“t use limit at all and use paging to get more results: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging

Periodically fetch Facebook like,share and comment count for all pages within domain

We are to create a statistics module for our news portal which involves crawling like and share count for each article (~7000 urls and continuously increasing).
The statistics is to be regenerated at least daily and without user iteraction.
We tried using fql without access_token (as it would involve user iteraction):
select ... from link_stat where url = ...
select ... from link_stat where url IN (...,...,...)
same with multiquery
But we are getting 403 Forbidden response after a few requests and the actual ip "banned" (all other requests without access_token result in 403) for some time.
Is there a proper way of collecting like and share counts for the particullar website?
A quick way to query facebook using FQL is to install the "fbcmd" app. This app lets you access the facebook and execute FQL statements from command line. It needs authorization once, during installation. After that, you can execute any number of queries.

Having trouble with Facebook FQL - Empty Return

I'm attempting to make a Facebook app that will query insights metrics from pages that I administer. I'm unsure if there is a better approach, but I am running into issue after issue trying to build my queries.
For instance, many of the "metric" fields listed here return empty data objects. Testing the following FQL query on the Graph API Explorer is an example (substitute with your page ID):
fql?q=SELECT metric, value FROM insights WHERE object_id=<USER_ID> AND metric='post_storytellers' AND period=0
I have granted myself "read_insights" permissions.
I'm wondering if this is a common issue, if I'm doing this wrong, and if there is a better way (i.e. FQL is problematic, stick to the Graph API). I started this project using Perl, intending to simply parse the return data into a database. Perhaps I would be better served writing this in PHP?
The post_storytellers metric, has only 3 available periods: day, week and days_28. When you put period=0, you are asking for the lifetime period.
Your query should be something like this:
SELECT metric, value FROM insights WHERE object_id=<PAGE_ID> AND metric='page_storytellers' AND end_time=1334905200 AND period=period('week')
I hope it would help!

How to retrieve ALL Facebook photos a person is tagged in

I know you can append limit and offset values to the graph.facebook.com/id/photos API call to paginate through photos. But large limits don't seem to work well, photos end up missing. I read here that limit=0 gives you all photos, but again photos will be missing. So what's the biggest limit you can use reliably? What's the proper way to efficiently retrieve ALL photos?
Is there documentation on the limits of limit?
Here's my experience with the Facebook API...
If you set a limit, you won't get any more than that. However, a large limit will most certainly give you less than you requested despite more existing. All of Facebook seems to run on a principle of "good enough" when it comes to responding to API queries. If you ask for 5000 items and after 5-15 seconds the system is only able to retrieve 350, then that's likely all you'll retrieve. There also seems to be a limit on size of content. So, the limit completely relies on the type of content you're querying and it's not a fixed amount. It's possible to say limit=5 and only get 4 items (even when more exist).
limit=0 used to give as many responses as possible, but I'm not sure if it still works. You can also use since/until to be more specific about the items you want to retrieve. But regardless, there's no way to know if you've gotten all possible responses.
I faced the same issue in our application. "me/photos" doesn't give complete data. One can understand the permission associated with photos but then also "me/photos" end up not returning even photos with "public" permission.
We were able to resolve this issue by taking following approach. Now our application returns all tagged photos except the ones having restrictive permission.
First we did find the list of IDs of photos in which user is tagged using FQL. This can be achieved as following.
FB.api({
"method": 'fql.query',
"query": 'select object_id from photo_tag where subject=me()'
}
,function(resp)
{
}
The above API will give the IDs of photos in which user is active. Now once the ID is available the details of photo can be fetched as following.
FB.api({
"method": 'fql.query',
"query": 'select object_id from photo_tag where subject=me()'
}
,function(resp)
{
var photoId = resp.object_id;
FB.api("/" + photoId, function(data){////DO THE PROCESSING/////////////});
}
The above process involve larger number of requests to Facebook, but till now this is the only way that we have found out to fetch all possible tagged photos.