Facebook API not returning all photos on a page - facebook

I'm trying to grab all photos posted by other users on a page, but for some reason facebook seems to skip seemingly random photos. I'm not sure if it was happening a few days ago, but if it was I didn't notice it. Here's the FQL Query I'm using:
SELECT post_id, actor_id, created_time, permalink,
message, attachment,
comments.count
FROM stream
WHERE source_id=me()
AND filter_key='others'
AND attachment.fb_object_type='photo'
AND created_time > #{Time.now.to_i - 60*60*24*5}
ORDER BY updated_time DESC
LIMIT 0, 500
Please excuse the ruby time method in there - it works without that line, even in the api explorer. Also, the API token is for the page, so the me() method works properly. It seems to skip random photos, even though they are all public and should be returned. Is this a bug or is there something wrong with the query? If I could do this in the graph API instead, I would love to know how.

Related

Get facebook check ins via FQL or Graph api

So what I need to achieve is to get all facebook check ins for certain user (myself, or my friend).
According to FB documentation over FQL that should be simple, for example:
SELECT author_uid, tagged_uids, target_id, timestamp FROM checkin WHERE author_uid = me()
But atm I'm not getting any errors, only empty data array in return, but obviously I have a lot of facebook check-ins also, if I tried with different author_uid's (friends of mine, all permissions are granted) I'm getting the same response.
For me this is not logical and if I'm doing something wrong here I would realy appreciate if u can point me in right direction ;)

How to display the last post of a facebook page on my webpage

I've got a facebook page which is publicly accessible. On my website I'd like to display the last post made by this page.
I made a script which uses the facebook php-api and FQL to retrieve the events from the page. But I just can't figure out how to construct a FQL which displays the latest posts from my page. I've seen the stream table and thought I should use it like this:
SELECT created_time,
likes, message, post_id, share_count, type
FROM
stream
WHERE
actor_id = {$page}
LIMIT 5
But that results in the fact I need a Starred/Indexable column. Fair enough, but I can't figure out which starred column to use.
Anybody?
You should use: source_id instead of actor_id

How to get Page's Posts by Others

I need to pull the 'Posts by Others' from my Facebook Page and display them on my site. Spent the afternoon fiddling around with the API and was able to see posts made by the page, but not others. Any ideas?
Steve, I just found another solution, you can use the Graph API using FQL.
Just make a call to the following:
https://graph.facebook.com/fql?q=SELECT post_id, created_time , app_data, type, actor_id, target_id, message FROM stream WHERE source_id = YOUR_PAGE_ID AND actor_id != YOUR_PAGE_ID&access_token=YOUR_ACCESS_TOKEN
If you need more variables, you just need to put them after SELECT, and you can check them out here: https://developers.facebook.com/docs/reference/fql/stream
On iOS, you don't need to put the access token in the query. To check how to do it with the latest iOS SDK, see my answer here: https://stackoverflow.com/a/14357179/675486
Got it, they are in the 'feed' field along with posts by the page. I was hoping for something that would just give posts by others, but I can filter out the ones posted by the page.

List of people who shared on facebook

I've been scouring the docs for a while now and can't seem to find a way to accomplish this. The information is available publicly (on a facebook page ... the link says "View all # shares") but I can't seem to find a way to access this info either via FQL or the graph API.
I know I can get a list of likes for a given post:
https://graph.facebook.com/87236249496_134765166623967/likes
The goal is to get a list of people who've shared -- but there doesn't seem to be the same sort of thing for shares. Am I missing something?
You can do it via "graph.facebook.com/OBJECT_ID/sharedposts" connection:
I figure it out this connection via metadata=1 parameter:
Go to... http://www.facebook.com/ajax/shares/view/?target_fbid=10154612868272801&__a=1
10154612868272801 is Facebook story ID, __a stands for asynchronous.
You will see large amount of text/JSON, it is basically HTML & JS for little popup window. There is portion of text like hovercard.php?id=# where # is Facebook user ID, using preg_match_all you then get all of the user ID's who shared that post.
Eg: 100000541151971 (Eric) and 9204448 (Courtney)...
Unfortunately, you must be logged into Facebook to do first step, figure it out :)
I think you can get the share_count from stream table by FQL query just like
SELECT type, source_id, share_count, permalink, description, post_id, actor_id, target_id, message , share_count
FROM stream
WHERE filter_key = 'others' and post_id = '87236249496_134765166623967'
you can test it https://developers.facebook.com/tools/explorer/
Note: you have to take the read_stream permissions as explained here
Tye this link: https://graph.facebook.com/134765166623967/sharedposts (with a valid access_token)
The id in the link is the wallpost id (87236249496_134765166623967) minus the page id (87236249496) and minus the underscore.
You'll also need the read_stream permission
I know you're looking to get at shares through the post_id, but can you settle for finding shares by page_id instead of post_id?
If you can, then you can use the following FQL to get the data you're looking for.
SELECT via_id, created_time, owner_comment
FROM link
WHERE owner = me()
You can then compare via_id against the posts author (page ID) to determine if this share came from the post author in question.
Unfortunately, there seems to be a bug with the data return where some of the via_ids come back as 0. There is a ticket in with Facebook which, at the time of this post, has been open for three weeks at medium priority. I have no idea if this issue is specific to my app or affects everyone, but that query might get you what you want.

Get wall posts made through my Facebook application using FB's API

I made a Facebook Application that people use to share links from my webpage to their walls, and now I need to get back a list of the posts made through it during a pediod of time (e.g. from Sep. 4th to Sep. 10th), incluiding their Post IDs.
I am aware that I could save that information at the moment of its publication, but I need some old data that I didn't save that way.
I have tried using FQL, but that requieres to indicate the source_id (Facebook ID of the user's wall where the post is on), which I am not able to know.
The Graph API object for my application doesn't seem to help either, since it doesn't have a connection for the posts made through it.
Any help would be really apreciated, even just a sign in the right direction.
As suggested, prompt the user for read_stream permissions, and then I'd suggest to take the fql route:
SELECT post_id, actor_id, target_id, message
FROM stream
WHERE attribution=[your app name]
AND created_time > [since]
AND created_time < [until]
AND filter_key in (SELECT filter_key
FROM stream_filter
WHERE uid=me() AND type='newsfeed')
It's not likely to be an issue, but be aware that there's a limit in the number of items returned, so if your time span is wide and your users posted a lot, you may have to play with the [until] and [since] a bit more and make several calls to retrieve everything.
Also take a look at the documentation for more information about fields you can query: http://developers.facebook.com/docs/reference/fql/stream/
Prompt the user for read_stream permissions and then query /me/statuses and look for updates from your application.