I am writing an application that needs to retrieve all posts on any given facebook page. For the McDonald's page, I would use this url:
https://graph.facebook.com/McDonalds/posts?access_token=xxx&limit=5000
The problem is that first, I do not receive any posts older than 2011-11-01 and the number of posts shown is much less than 5000. This means that the limit parameter isn't working properly. I looked this up and found that it was a known bug.
Then I tried to follow the next and previous paging information provided in the end and even using that I can't get past 2011-01-24. After following the next link 2 times, an empty page comes up. The McDonalds page is much older and contains more posts. So the question is, how on earth am I supposed to retrieve older posts. Is there any workaround at all?
There is a limit on the limit. Try using since & until to extend the date params
https://graph.facebook.com/McDonalds/posts?access_token=xxx&limit=5000&since=2+years+ago&until=now
&limit=5000&since=2+years+ago&until=now
&limit=5000&since=3+years+ago&until=now
Related
I'm trying to get number of likes on videos. So I go like
https://graph.facebook.com/v4.0/{video_id}/likes?access_token={token}.
However I always get back empty data even if video has at least some likes.
I've created a token with following permissions: scope="public_profile,email,user_videos,manage_pages,user_likes".
The last thing to mention is that the video is posted by user page. I've also tested the same thing on Graph API Explorer and it doesn't even work there.
I for example can get comments on the same video...
The individual likes are likely not available to your app due to privacy concerns (the liking user would probably have to grant your app access to access their made likes first)
But since you are only interested in the overall number, asking for the summary should do it:
/{video_id}/likes?summary=1
or when using field expansion syntax,
/{video_id}?fields=likes.summary(1)
Let's say I want to search for McDonalds in a certain location using Facebook's graph API, like so. Now, since I know that Facebook won't always give me back all the results I want on the first page, or even the number of results I asked for, I follow the pagination link. This is the one I was given. Now, this second page loses the query string, and returns a bunch of results near the search location, but having nothing at all to do with McDonalds (e.g. Tufenkian Artisan Carpets Chicago). How can I tell when I have no more applicable results, if the pagination drops my original query entirely?
It looks like removing the limit parameter causes pagination to correctly have the query on future pages: see the same search without the limit parameter.
Could someone do me a flavour and let me know if you also get back an empty json array when you click on the sample user search url on the Facebook Graph Api docs page.
Here is the page http://developers.facebook.com/docs/reference/api/
It is in the search section. the people link.
Here is the link I am clicking and all other search links return data except the user search.
This is what I get back
My question is do other people have this problem as well or is it just me.
My suspicion is that it has to do with the way Facebook filters by privacy after they've selected your results. Meaning graph asks for (X) results, Facebook finds (X) results that match your search, then removes those who have it in their privacy options not me be searched, and then after filtering returns what's left. This is explained on Facebook's dev blog: https://developers.facebook.com/blog/post/478/
See the following answer for clearer details: https://stackoverflow.com/a/11848002/624590
That said, it could be something else - I've noticed it's been getting especially bad in recent weeks; fewer and fewer results seem to be returned.
We've been getting empty results for type=post for periods of 1-2 hours for the past few days. I'm sure it's related to something on their end, check out my bug post here http://developers.facebook.com/bugs/456910301017301?browse=search_509b0461dc68c0151458645
Say I have a website that has 100 products. Then this is filtered down to 5 sections containing 20 products each. If you were in one of the sections that contained 20 products (e.g. toys), what would be the optimal method to display only 5 toys per page. At the bottom of the list would be next/previous buttons to show the next/previous set of 5 toys.
A better analogy would be google search. There are millions of results but only ~10 are shown at a given time.
So right now I'm using google app engine (python) and django templates. One way I thought of to remedy this problem would be making all the query results go into a div which could then be modified through javascript to give a similar effect. However, if someone were to click their browser's back button, they wouldn't go where they originally came from.
Thanks in advance. Any help would be useful...I don't know what this technique is called so google hasn't been really useful :(
Edit: based on responses, I found my question was solved here: How to use cursor() for pagination?
Look into query cursors. Thay are made to be serialized and sent to client, to be used in creating "next" and "previous" paging requests.
NOTE: don't use offset on queries. This can be VERY expensive, as it actually fetches (and charges) all entities up to offset+limit position, but returns to application only limit results.
I'm not sure that putting all the results as hidden content in the HTML and manipulating it using JS is a very good idea if you might have a large result set (think about what happened if Google used this approach). There's also the back functionality issue that you've mentioned.
So, as for querying a wanted "results page" each time, I think the Google's GQL Reference might help you, take a look specifically at the LIMIT clause, it can help you create the paging mechanism you're looking for by supplying it with the number of items-per-page you want as "count" and the numbers of items-previously-viewed as "offset" (0 at first call).
As for displaying, I think that the Google Images / Facebook News Feed approach might also be interesting to think about (loading on scroll instead of paging), but that's a matter of your personal choice :)
Hope this helps, good luck!
EDIT: After reading Peter's answer, I found it much more efficient to use cursors for pagination, a good reference is given in his answer.
We have a worldwide brand page that posts brand messages and filtered by country, for example: "This is visible in the US" (visible to United States), and "This is visible to Russia" (only visible to Russia).
Main Question: Is it possible to retrieve posts on the page wall filtered by country or other location parameters? For example: https://graph.facebook.com/[userID]/feed?access_token=[accessToken]&locale=en_US
Side Question: Currently when using the URL above (without &locale...) returns only the posts available worldwide, and all targeted posts are not returned. This could potentially be due to the access token being used as I am able to return info for page feeds (that I own) for all locales using a different access token. Is there a correlation between application tokens and locales that are returned?
Forget about it - it's impossible. They never thought about providing us any interface to this.
What you must do is:
Download the entire graph object (awesome especially on mobile),
Remember to download all pages (since facebook is paging long responses),
Merge and filter them on your side (or in client's browser|phone),
VoilĂ you're good to go ;) .
PS. I know you asked this looong time ago, but it's still one of the first Google results for related queries, so I'm writing here so others can quickly find out. Cheers!