Get facebook check ins via FQL or Graph api - facebook

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 ;)

Related

Getting friends' facebook check-ins into a place

I'm trying to find which of my friends have been to Paris before. I'm trying to use the Graph API to do this.
So basically there's the place id (for Paris it's 110774245616525), I can get basic informations using the endpoint https://graph.facebook.com/110774245616525/ to do this. Then, I'm getting an access_token with friends_status and user_status permissions (using the Graph Explorer) and I'm using this access token to get the checkins. So I'm doing a GET https://graph.facebook.com/110774245616525/checkins?access_token=my_access_token call and all I get is this error message :
page_id is not a member of the checkin table
Although, reading the documentation I see the connection with checkins :
Checkins made to this Place Page by the current user, and friends of
the current user.
Is this an error with the Graph API or with the way I do it?
Thanks !
There's a breaking change for checkins in the July release https://developers.facebook.com/roadmap/ it mentions renaming page_id to target_id so this might be what's causing it. However the following fql query might be a starting point for you
select author_uid from checkin where target_id = 110774245616525
author_uid should be the person who checked in https://developers.facebook.com/docs/reference/fql/checkin
I got the following fql to work to display all the names of my friends who have checked in at a specific location. Only tried it in Graph API Explorer, and it was fairly slow :/ Let me know if it's helpful :)
Select name from user where uid in (Select author_uid from checkin where author_uid in (select uid2 from friend where uid1=me()) and target_id=110774245616525)
An additional note: I noticed that many of my friends show up in the "Friends who have visited Paris, France" box, but they don't have any actual checkins there. I think that the box also checks to see if your friends have any photos from paris.. Just a thought
With the help of asifrc and TommyBs I found a way to do this in FQL using this query :
SELECT name
FROM user
WHERE uid IN (
SELECT author_uid
FROM location_post
WHERE distance(latitude, longitude, "48.856614", "2.3522219") < 5000
AND author_uid IN (SELECT uid2 FROM friend WHERE uid1=me()))
It's pretty much getting all my friends, searching all their posts close to the center of Paris, then getting their names.
If anyone knows how to do this in Graph API, please let me know, because it's still not a good idea to rely on FQL, I think.

Facebook API not returning all photos on a page

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.

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.