Get Facebook post's comments using graph API by post URL - php

I like to get comments of a post by its URL but it seems its impossible by using graph API.
From my observations, I could find these types of posts URLs:
https://www.facebook.com/bbwbooks/photos/a.168788885097.122872.74209335097/10153736545150098/?type=3&theater
https://www.facebook.com/4thirteengroup/posts/1285218878169361
https://www.facebook.com/groups/semsari.malezi/permalink/1159959294084128/
or perhaps some other types.
Is there any idea, how its possible to get comments or at least the ID of the post from the url?

First use facebook developer section https://developers.facebook.com/tools/explorer/1021611514583622?method=GET&path=me%2Fposts%3Ffields%3Did%2Cobject_id%2Ccomments&version=v2.7
Select Application ,
Get access_token with user_posts access rights,
me/posts?fields=id,object_id,comments by calling this api ,you will get all posts with their comments

Related

Get my posts on facebook manage page

I need get ME posts in one of my manage pages, with the new version of facebook sdk.
Example:
I'm manage on Page A, and add a post in my name Adexe Rivera, and in this page there are a lot of posts. So I want to filter only posts by Adexe Rivera.
I know for get posts on pages it's necesary /page/feed, but I need add the filter from user.
I tried with Graph Api Explorer, with this FQL:
SELECT source_id, actor_id, post_id, target_id, message FROM stream WHERE source_id = "PAGE_ID" AND actor_id = "MY_ID"
and get the information that I'm searching.
But I know that since v2.0 FQL not works for sdk, so that I need it's make the same like FQL works in this version of graph
I already tried what documentation said, but not get my posts.
A user access token is required to retrieve posts visible to that person.
Thanks in advance
Filtering is not possible, you can only use the existing endpoints and filter on your own after getting the entries. There are several different endpoints, make sure you are using the correct one. They are all documented very well: https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed
Also, an App Access Token should be enough to get access to the endpoints if it´s a public post on a non-restricted Page:
An access token is required to view publicly shared posts.
If you don´t know about Access Tokens, read those articles:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
Finally, it is not possible to use FQL giving me the expected result, so getting the "from" field in the /PAGEID/feed endpoint, and filtering the results, I get what I wanted.
Thanks for your answers and for their penalties, I have spent several days trying to maximize the performance of the SDK facebook.
Cheers

Get Facebook id of person how tagged me on my timeline

Currently i'm working on a website for a client.
I want to show his latest Facebook wall posts on his website, also posts he is tagged in by others.
With the Facebook Graph i can get allot of data from the latest post like message, description, picture etc. But i just can't find or get the Facebook id of the person who tagged him in that post... Only his own Facebook id and the id's of the others persons who where tagged, but not the tagger (if that is even a word :P)
Can anybody help me with this?
I'm using /feed in the Facebook Graph to get the data from the posts on his wall
$fb_id = 'your-facebook-id';
$fb_token = 'my-acces-token'; // tokken obtained from Facebook graph explorer page
$fb_response = file_get_contents('https://graph.facebook.com/'.$fb_id.'/feed?access_token='.$fb_token);
$fb_array = json_decode($fb_response, true);
Thanks for your time!!
If I understand you correctly, you just need to find the ID of a user that posted a status update that tagged your client.
Do things as you were before, by collecting objects from the /user/feed edge. You should retrieve an ID for the status. With this, make another call to the Graph for /STATUS_ID. This will give you information about who posted the status along with other things.
https://developers.facebook.com/docs/graph-api/reference/v2.1/post
Note that this will only work for public posts with any valid access token. If the post is not public, you may not be able to retrieve the post with a user's access token that is not the original user who posted the status. Keep in mind that the docs specifically state:
Only posts whose authors have also granted read_stream permission to the app will be shown for /user/feed.

Tumblr - Facebook post like status statistics

I want to implement the following features.
From my server I want to write a script which will authenticate a user's tumblr and facebook account and will extract
like statistics comparison data
from corresponding posts.
Anyone have any ideas.
I tired to extract the information using the tumblr API but did not get any useful information to fulfill the requirements
Tumblr likes are classed as post notes.
From the API documentation you can get post note information as follows:
http://api.tumblr.com/v2/blog/BLOGNAME.tumblr.com/posts?id=XXXX&notes_info=true
Adding the parameter notes_info=true will return the note / like count.

Facebook API - Check Likes and Comments of Post

Is there a way to check the number of likes and comments that a particular post has? I wanna display that number on my site so i need to reference the API somehow to get that result. I am looking for either a PHP or a javascript solution. This will also be done dynamically. I want to keep track of likes posted by my app to different users so I'm thinking i should store the post id when I make the post. Any ideas?
Each post in facebook has a specific Id
You can use graph api to grab this id and see all the comments, likes and shares of it.
You simply have to make a POST call and grab the produced JSON
More information can be found on the links below
http://graph.facebook.com/19292868552_10150189643478553
https://developers.facebook.com/tools/explorer/?method=GET&path=19292868552_10150189643478553
https://developers.facebook.com/docs/reference/api/post/

Get a list of all the shares of a facebook post

I can get a list of comments and likes just fine using the facebook sdk. But i can't
find a way to get a list of all the users that shared a post (i tried fql as well).
This is the code i used to get the likes:
$facebook = new Facebook($config);
$likes = $facebook->api('/THE_POST_ID/likes',
array('limit'=>9999999999));
At the time of writing this, Facebook Graph API allows you to get the count of shares of a post. Using your code, it would look like the following (please not that I'm not doing any exception handling here for keeping the example simple):
$facebook = new Facebook($config);
// fetch the post data.
$post = $facebook->api('/THE_POST_ID/');
// fetch the count of shares.
$sharesCount = $post["shares"]["count"];
Using the Graph API Explorer you can easily see that.
Unfortunately, the API does not provide a "shares" connection like it does for "likes" and "comments". See Post - Facebook Graph API Documentation for details.
On the other hand, there is a dirty hack for retrieving the list of users (only friends and people who shared publicly) who shared a specific post. The solution is explained on another thread: List of people who shared on facebook. But, I would never suggest using that solution.
Yes you can get list of all the shares of a facebook post.
by accessing:
https://graph.facebook.com/{POST_ID}/sharedposts?access_token={ACCESS_TOKEN}
See:
https://developers.facebook.com/docs/graph-api/reference/v2.5/post
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.

Categories