Trouble with FQL stream_tag - facebook

I am trying to retrive posts from a users news feed in which my fan page has been tagged. I'm seaching through stream_tag with FQL but zero results are returned.
Posted a comment on my wall in which I tagged a friend, myself, and my fan page.
Used the Graph API Explorer - developers.facebook.com/tools/explorer/
Used the explorer as one of my apps, and granted every type of permission.
Did the following query:
https://graph.facebook.com/fql?q=SELECT post_id,actor_id FROM stream_tag WHERE target_id = [fan page id]
The following is returned: data: []
This seems to indicate that there is no resaults but I know the tag exists. When I do a query with target_id=me() results are returned, but according to the documentation the target_id can also be a fan page( http://developers.facebook.com/docs/reference/fql/stream_tag/ to craft the query).
How can I create a query that returns posts my fan page is tagged in?

I was trying to do the exact same thing when I came across your post. It looks like there currently is a bug report open that the stream_tag table does not work with when the target is a page.

Related

Facebook Graph API - Getting time of the 'Like'

I am trying to get the time of the 'Like' using facebook api
https://graph.facebook.com/v2.5/feed?fields=likes{id,created_time}&access_token=MY_ACCESS_TOKEN
It works for comments but not for likes
https://graph.facebook.com/v2.5/NFL/feed?fields=comments{id,created_time}&access_token=MY_ACCESS_TOKEN
The documentation is also not consistent and doesn't give any details about this i.e. there are other fields for the 'Likes' edge such as 'profile_type', 'pic' etc... that show up in the Graph API Explorer but not documented.
The docs are actually consistent if it does not work for likes. The likes edge returns a list of Users, but the User table (obviously) does not have a field for the like time. The comments edge returns a list of comments, they do have a created_time field: https://developers.facebook.com/docs/graph-api/reference/v2.5/comment/

Getting 'pic-square' from user posts on the news feed using Facebook Graph API

I'm trying to get the 50 x 50 profile picture for user posts on the news feed. It's easy to do this for likes and comments on posts but I can't figure out how to do it for the initial posts.I also want to limit the query so that I only get results from "people" not "pages" and I only want unique results. In other words if a user appears twice on the feed I only need their picture once. I've played with the Graph API Explorer extensively and have looked all over the forums, here, as well as the documentation on the Facebook developers site. I would think this would be a common request so I'm not sure why it's been so hard to find.My guess is that the syntax of the query would look something like this. Although this query doesn't work in the explorer.
me/home/?fields=from.id.fields(pic_square),from&profile_type=user
Well after a lot of research and trial and error with FQL I figured it out. It's a series of nested queries and it returns an array with the urls of the pic-square images of the users whose posts appear in your news feed. The FQL query looks like this:
SELECT pic_square FROM user WHERE uid IN (SELECT actor_id FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me()))
I was not able to differentiate between user and page profile pics.

How to retrieve links posted by third-party Facebook apps?

I am trying to build an app that fetch all the links posted on a Facebook page. I'll use the Kotaku page as an example (https://www.facebook.com/kotaku, Facebook ID is 273824104039).
I have tried to get the links via the graph API (https://graph.facebook.com/273824104039) or via FQL (here is the query I used: SELECT link_id, owner, title, url, owner_comment, summary, created_time FROM link WHERE owner = 273824104039), but both of them only return a subset of the links posted (20 as of writing this post).
(All request were made with an access token from my account that I granted the read_stream permission. I also 'like' the Kotaku page, but according to the documentation the links connection is available to everyone on Facebook.)
If you go on the page, it's pretty obvious that there are more than 20 links, but most of these were posted via the dlvr.it app and those are not showing in the queries above.
So does anyone know it there is a way to get those links as well? If possible, I would like to get all the links posted on that page not just the last 50 or from the last 30 days.
I think the issue is that links posted by apps aren't treated as native Facebook links, they're just posts with attachments, so you're not likely to find anything in links. With that said, try looking at the stream FQL table or the posts parameter of the graph.

How to know how many users "like" something [facebook]

How to get how many times specific object was liked?
Answer: http://developers.facebook.com/docs/reference/fql/link_stat
and
How to get the most liked links in my application?
UPD 3: another question then: how to get the object_id for given liked page
Answer: object_url fql table
You can use a SQL (FQL) query and then count the users who liked the object. Heres information on the query: http://developers.facebook.com/docs/reference/fql/like

Get Facebook Link Likes

Using the Facebook API with the FQL language, how can I get a list of the users that liked a given URL? I got the URL and want to query Facebook to see how many people and what users liked that URL.
Using PHP or ASP.Net... doesn't matter, just want to know how to write the FQL query.
Sadly this data isn't available. What's possible via the Link Graph API objects and the link FQL table is just retrieving a given instance in which a link was shared by a user. You can get the count of likes on a user's posting of a link, but this likely isn't what you want.
Discussed this 3-6 months ago with guys at Facebook, and the consensus then was also that getting this data via API is impossible. As far as I know things haven't changed, and there are some privacy arguments for keeping this data out of the API.
'SELECT user_id FROM like WHERE object_id IN (SELECT link_id from link WHERE url = 'YOUR URL HERE' AND owner = 'YOUR USER ID HERE' '
Like FQL Table
Link FQL table
In order to access user's likes, the application needs to have user_likes permission from the user. After that if you access http://graph.facebook.com/me/likes with appropriate access tokens, all the object IDs (including external websites), the current user has liked will be listed.
(this is in reply to bounty question, which seems a bit different from the original question asked on this page)
It's not using FQL but...you can see the most recent 500 users that have like your page by going to: https://www.facebook.com/browse/?type=page_fans&page_id={id} but you would have to scrape this to get the information and it won't work for more people besides the most recent 500. Here's the gotcha, you've gotta be an admin of the page_id to see it.
You can only get the fans of pages that you are an administrator for. So you have to provide an access token with your request associated with an admin account of the page you are trying to get the fans.
Facebook's FQL documentation here: https://developers.facebook.com/docs/reference/fql/page/ tells you how to do it. Run the example SELECT name, fan_count FROM page WHERE page_id = 19292868552 and replace the page_id number with your page's id number and it will return the page name and the fan count.