How to get the posts that a friend reshares using FQL? - facebook

I faced with the following problem. I would like to know how to get all the posts that has been reshared by my friend using FQL. I use the following query:
SELECT post_id, type, source_id, actor_id, target_id, via_id, app_id FROM stream WHERE source_id=<friend_id> AND via_id LIMIT 0,100
but unfortunately it returns an empty list. At the same time, when I execute the following query for my account I get the list:
SELECT post_id, type, source_id, actor_id, target_id, via_id, app_id FROM stream WHERE source_id=me() AND via_id LIMIT 0,100
I generated a token for all possible permissions. Could someone, please, point me how to solve this problem?

Your both queries are correct.
SELECT post_id, type, source_id, actor_id, target_id, via_id, app_id
FROM stream
WHERE source_id=<friend_id> AND via_id
LIMIT 0,100
It is only that, through the API, you can't access Users from depth 2. For instance, it is impossible to get your friends' friendlist.
If one of your friends shared one of your friend's post, then you will see one result.
If one of your friends shared a random user's post, then no results.
For privacy reasons, the API only allows to access the information in a quite closed circle of friends.

Yeh.. I was wondering about the question as well for some time..
Using Graph API we can get all the links that I have shared..
GET me/links?fields=link

Try this:
SELECT via_id, link_id, caption, url
FROM link
WHERE owner={user_id}
via_id will show you the unique identifier of the original link poster. If via_id=0 you are the original linkposter.
At least it will work for links.

Related

FQL query doesn't retrive all data it should (some results omitted)

I'm trying to get all posts by users on a page with this query :
SELECT post_id, source_id, created_time, app_data, type, actor_id, target_id, attachment, message FROM stream WHERE source_id = MY_PAGE_ID AND actor_id != MY_PAGE_ID LIMIT 50
The requests actually works, but some posts are omitted.
If anyone had also this issue, and know how to solve it, it could be very helpful. If you know also a better way (which works well) to get all posts by users on a page, it could help.
Thanks.
Hi i am using below fql and it is working fine for me. Hope this helps.
https://graph.facebook.com/fql?q=select+post_id,source_id,created_time+**"OTHER FILEDS REQUIRED"**+from+stream+where+post_id+in(select+post_id+from+stream+where+source_id=" **YOUR PAGE ID** ")&access_token="**ACCESS TOKEN**"

FQL not returning all items in stream

I am building a web app that allows users to post to Facebook as well as view their news feed (among a bunch of other things).
This: https://graph.facebook.com/me/posts returns way to many records. It returns EVERYTHING.
To limit the results to Link, Photo, Status Message, Post, and Video, I opted to use FQL. I using the following in my call:
SELECT post_id, source_id, actor_id, target_id, message, attachment, permalink, type FROM stream WHERE source_id = me() AND type IN (80,247,46,128,56) AND is_hidden = 0
The problem is that I am getting back only records created by my app.
What am I doing wrong?
Thank you.
Evidently, all that is required is a LIMIT statement. It works fine now that I have added a LIMIT.

How to query stream table to get updates when some of my friend is tagged in a photo

my project requires get updates from my friend when they are tagged in a photo. On facebook site, such kind 'someone is tagged in a photo' message is automatically categorized in one of my frined list (for example: close friend) other than the news feed category. So I use below FQL to query the stream table:
SELECT post_id, source_id, updated_time, created_time, actor_id, target_id, message, attachment, comments, likes
FROM stream
WHERE filter_key in
(SELECT filter_key FROM stream_filter
WHERE uid = me() AND type = 'friendlist')
AND is_hidden = 0 ORDER BY created_time DESC
But unfortunately, all updates I see on the facebook site exist in the query result except for the photo tag updates.
Does anyone know what's the issue or how can I retrieve such photo tag updates ?
Thanks
Similar question here: How can I get "is now friends with" and "was tagged in" posts in Facebook Graph API?
Unfortunately the answer isn't what you want to hear.

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.

Graph api get facebook app data

I was wondering if it's possible to get data from apps, such as discussions or extended info through Graph api or FQL? I'm using the PHP sdk, though it shouldn't matter much.
It isn't possible. Can't be done.
I couldn't understand what you exactly want..
But I think if you need information related to app there is a graph api available for this, please refer the documentation from the following link,
http://developers.facebook.com/docs/reference/api/application/
The feed connections of application graph object could get the feed for the application..
If you are not looking for this, can you explain a bit further about what you need exactly.
To get posts and comments from wall of some Facebook application you may test here following FQL query
SELECT
post_id, viewer_id, message, app_id, source_id,
created_time, updated_time, filter_key, attribution,
actor_id, target_id, message, app_data, action_links,
attachment, impressions, comments, likes, privacy,
permalink, xid, tagged_ids, message_tags, description_tags
FROM stream WHERE
source_id = {ID_of_wall_of_your_App}
where url of my app's wall is as follows:
http://www.facebook.com/pages/display_name/ID_of_wall_of_your_App#!/pages/display_name/ID_of_wall_of_your_App?sk=wall
I'll make one more an update later.