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

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.

Related

Extract facebook users IDs who like or comment a post

I wonder if anyone knows or has a tool which allows to extract the list of users IDs who liked or commented a Facebook post (especially a page post).
I've tried many softwares that claim performing this task in vain...
If you have a miracle, please share the love. I'd be glad to have either a software name, a java script, or anything that can do so.
Thank you all.
Would you mind telling what are you going to do with this?
Answer
263907926200 is the sample post id used
Through browser
https://graph.facebook.com/263907926200/comments
https://graph.facebook.com/263907926200/likes
Through API Explorer
->/v2.2/263907926200/comments
->/v2.2/263907926200/likes
FQL Method if you have an old app
Likes
https://graph.facebook.com/fql?q=SELECT user_id FROM like WHERE post_id = "xxxxx_xxxxx"
Comments
https://graph.facebook.com/fql?q=SELECT fromid FROM comment WHERE post_id ="xxxxx_xxxxx"

Loading page post data from 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.

Get permalink to a post published on user's wall

Using Facebook dialogs, app users can share stories. I wish to be able to construct a permalink to the published story and offer as link to view the post. What we receive in response is the post_id, which alone doesn't look sufficient.
Would it possible to construct a permalink based alone on the post_id, if not, what other approach are possible?
Thanks a ton for your time.
You can constuct a link to the original posts with the post_id in the URL with this pattern:
http://www.facebook.com/7683938373/posts/7938393003
where the post_id is 7683938373_7938393003. (This is a made up post_id)
Just as a note: You can also access a permalink field from the stream table.
Johnny
Isn't it in the response when you access the post via its ID in the API?
There should be a permalink in there in the actions object which you can direct the user to for them to like/comment on the new post

How do I pull the name of the user that posts to our page wall?

I have looked through and couldn't find the answer on here...
We are doing a promotional giveaway and have a ton of addresses of people trying to get free stuff. What we want to do is give the people who post most on our facebook wall a better chance of winning.
So I am trying to set something up (I'm guessing using Graphs API/FQL) that will pull the name of the person who posted to our wall or commented on one of our posts. If I can get a list like this, I have enough php/mysql experience that I can create the code to compare the name with the database and weight their entry.
Does anyone have a simple explanation on the code to pull just the names of the people who posted each time?
Thank you so much for your help!!
Using FQL you can get the ids of those who posted on your page wall:
SELECT post_id, actor_id
FROM stream
WHERE source_id = "PAGE_ID"
and those who commented on posts:
SELECT post_id, fromid
FROM comment
WHERE post_id = "POST_ID"
You also should be able to combine them:
SELECT post_id, fromid
FROM comment
WHERE post_id IN (SELECT post_id
FROM stream
WHERE source_id = "PAGE_ID")
Once you have the ids you can simply query: https://graph.facebook.com/USER_ID and get the name of the user.
If you have too many and don't want to issue a request per one you might want to consider using the Batch Requests option.

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.