How to get fb posts of a mentioned page - facebook

I'm admin of a Facebook Page and i'm trying to get by API or FQL, contents posted on private streams wall mentioning my page.
If i try
SELECT type,target_id, post_id, message, actor_id, tagged_ids FROM stream WHERE source_id=PAGEID
i will get only: my posts(or page's) on the page wall, posts by a user on the pages wall, but i can't see posts by a user on their own wall that tags the page.
*Every user that visit my page can see them, so they should be accessible* by some API...but i can't understand how.
Thanks

You should be able to get this information by querying the stream_tag table, but in my tests I can't get it to return any data.
If the posts are visible on your page, you should be able to get at the posts mentioning you with this query:
SELECT type, target_id, post_id, message, actor_id, tagged_ids
FROM stream WHERE source_id =PAGEID AND actor_id !=PAGEID

Related

Is "Reach" of a particular Facebook post "public"?

I've been searching through docs but can't find a definite clear answer.
The Likes,comments and shares of a particular Facebook post are public i.e. If i query via fql the summary(insights) of a public facebook post from any random public facebook page,it would return the likes,comments,shares of that FB post.
I 've been trying to know "Reach" of a particular post of a random public facebook page,but in vain. Is it known only to Facebook page admin/owner?
You can get the impressions of a post with the following query-
SELECT post_id, actor_id, message, impressions FROM stream WHERE actor_id = {owned_page} and source_id = {owned_page}
But yes, you need some permissions- manage_pages, read_insights, read_stream etc. to fetch the impressions.
Here I've explained the same in detail.

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

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.

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

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.

Facebook Graph API: How to filter home & feed by application?

The Facebook Graph API lets you grab a JSON representation of home (News Feed) & feed (Wall).
How do I just get the posts made by my Facebook app?
Facebook has added support to filter me/home posts without using FQL by passing the filter parameter.
For example to get just photos you can do:
me/home?filter=app_2305272732
Full documentation is here: http://developers.facebook.com/docs/reference/api/user/#home
You can now run Facebook Query Language (FQL) queries using the Facebook Graph API (base URL: https://graph.facebook.com).
Let's say your application is Twitter. Twitter's Facebook application ID is 2231777543.
I came up with the FQL queries below with the help of #danontheline's answer and by carefully reading Facebook's documentation on FQL stream & FQL stream_filter.
The following excerpt is particularly pertinent:
If you specify a filter_key from the stream_filter FQL table or
multiple users, results returned will behave like the user's homepage
news feed. If only one user is specified as the source_id, you will
receive the profile view of the user or page. You can filter these
profile view posts by specifying filter_key 'others' (return only
posts that are by someone other than the specified user) or 'owner'
(return only posts made by the specified user). The profile view,
unlike the homepage view, returns older data from our databases. In
the case of a Page, the profile view also includes posts by fans.
Twitter Tweets on Your Facebook News Feed
GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE filter_key = 'app_2231777543'
Twitter Tweets on Your Facebook Wall
GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE source_id = me() AND app_id = '2231777543' LIMIT 1000
Running these queries with the Facebook Graph API Explorer returns Facebook Graph API post objects (The result set will differ depending on access_token, privacy, etc.). You can find out more about each post by adding other columns of the stream table to the queries above and/or by simply making another Graph API request to GET /{post_id} for eache post_id returned by the FQL stream queries above.
Afaik thats not possible with just the Graph API. But you can just use a FQL statement to retrieve the wall/feed, too. With this technique you are able to resrict it to the posts made by one actor_id (which should be your app ID in this case):
SELECT post_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0 AND actor_id = 'MattDiPasqualesAppID'
Thing here is that it won't return a JSON, but a XML representation of the result. With phps DOM class you are easily able to convert it into a JSON format or any other representation you want to have of the result!
As you might be handling the whole thing with PHP anyway, you also could just take the json array, parse it into an array and filter the array with keys of your appID.