Loading page post data from facebook - facebook

I'm trying to load a single page post data from Facebook. As you may know some posts have IDs like PAGE_ID + '_' + POST_ID and some have just POST_ID. When I have Page_ID and Post_ID available (I get these IDs from ad creatives), and want to get the post data, I don't know if I should call
https://graph.facebook.com/POST_ID
or
https://graph.facebook.com/PAGE_ID_POST_ID
Is there a normalised way on graph api to get post data? Should I make another request if one of the above fails?

A post_id is a universal unique id in the Facebook Grap. For as answer to your question:
https://graph.facebook.com/POST_ID
The post_ids have indeed sometimes some logic that is like pageid_postId. But don't think about it. PostId is uuid in Facebook.
And if you have more questions or issues you can easily the GRAP explorer and enter whatever id and check the result:
https://developers.facebook.com/tools/explorer
And enter the id in the text field after the GET dropdownlist.

Related

Facebook Graph API - get postst posted by my aplication

How to compose request which is retrieve wall posts posted by my application or at least I want to get ALL posts posted by any application or user. Now I can see only posts from myself and friends : me?fields=feed with permission read_stream. If it impossible withGraph API how to do this with FQL ?
select message from stream where source_id = DESTINATION ID and app_id= YOUR APP ID
If you want to filter by stuff your app is posting you have to find the id that your app is posting on. This is the "soure_id" ie where your post is going. Then you just have to add the parameter of what your app_id is that your app is posting as. If you wanted to filter by user you would just insert their uid as the actor_id instead of app_id.

Getting a list of everyone that likes a link.

If I create a page, is it possible to get a list of all the people that like that page on facebook. For example, if I create http://www.facebook.com/honeybadger, as an admin can I get a list of everyone that likes it?
You can't get a list of users who like a URL or Facebook page anymore. Facebook has gone and taken the page_fan and url_like tables and made the only indexable column on these the uid field.
Trying something like this
SELECT uid FROM page_fan WHERE page_id IN (SELECT page_id FROM page WHERE username = "honeybadger")
Throws an OAuth exception: "Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql"
The only thing you can do is create an app, have users authorize your app, then test if an authenticated user likes a specific page or link. If you ask for the right permissions, you can also test to see if their friends like your app.
This change was implemented to prevent spammers from harvesting Facebook IDs from their page fans or url likers.
The Facebook documentation seems to give the exact answer to your question.
https://developers.facebook.com/docs/reference/fql/like/
SELECT user_id FROM like WHERE object_id = <INSERT_FACEBOOK_OBJECT_ID_HERE>
simpler way is to get it thru graph api
https://graph.facebook.com/honeybadger/likes?access_token=valid_access_token

How to retrieve the comment and LIKE count of a facebook post

I am trying to execute following FQL and the result is always an empty XML
https://api.facebook.com/method/fql.query?query=SELECT post_id, comments.count FROM stream where post_id = 167995709886177
<fql_query_response list="true"/>
This is the post and it has lot of comments and LIKEs
http://www.facebook.com/ryanleslie/posts/167995709886177
Please help
#Anz just go through facebook developer section. all your doubt solve their
You need to use a URL like this:
https://graph.facebook.com/100002725117360_142921995808637?access_token=154407880175|16a3d55d6e4be468d6a131bc.1-100002735407608|IhahmvIUsur7GuZ45rxRj3boXtE
The bolded id (100002725117360_142921995808637) is the ID of the post. The part before the underscore is the user id of the person on whose wall the post appears, and the part after is probably the ID you are using in the example.
This will give you everything you need -- comments, likes, etc. If you want even narrower info, you can do that with URLs like this:
https://graph.facebook.com/100002725117360_142921995808637/likes?access_token=154407880175|16a3d55d6e4be468d6a131bc.1-100002735407608|IhahmvIUsur7GuZ45rxRj3boXtE
Note: this is a test user account, so I'm not exposing anyone's private info here.

Get links that friends have "liked" on facebook

I was wondering how to build a FQL query where i could receive links/urls of my app that an user's friends have liked. I got the link table which looks good but there i need an object id, which i dunno how to retrieve for my urls.
You can get the object id from the object_url table.
https://developers.facebook.com/docs/reference/fql/object_url/

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.