When you query the stream table for a fan page wall contents, you get back contents posted on the fanpage wall mentioning the page and also posts from a fan on their own wall which mention the page. Is there a way to distinguish between these two types in the stream response?
For example, here is a fan page http://www.facebook.com/signalhq which pulls a post from a user who has tagged the page in his own post
http://www.facebook.com/jeff.judge/posts/10150356144351153
Is there a way to differentiate this above post from other posts on that wall? I can't find anything in the fql stream api doc to accomplish this.
When you pull this post in JSON format from the Graph-API, There are "from" and "to" JSON objects in it as well...
They should be able to help you in distinguishing between the two posts
HIH!
As a slight modification of ifaour's post, you should run this FQL query:
SELECT target_id, post_id, message, actor_id, tagged_ids FROM stream WHERE source_id = PAGEID
The target_id field will allow you to know the object that the Post was made on. If this was the user posting on their own wall (and tagging the Page) then the target_id won't be the Page's ID. If the user posted on the Page wall AND tagged the Page in that post, then the target_id will be the Page ID.
Check out target_id on the stream FQL docs to make this clear: https://developers.facebook.com/docs/reference/fql/stream/
Edit: Clarification of the results you should be seeing:
A Post by the Page on the Pages Wall:
A Post by a user on the Pages Wall:
A Post by a user on their own wall that tags the Page:
Hopefully this should help you to differentiate?
An easy way would be retrieving the
tagged_ids
field:This would return something like:
If the page ID presents in the
tagged_ids
field and theactor_id
is NOT the page id then the page is mentioned by a user.