get likes and comments of facebook post after sharing it - php

User sharing contents in facebook like this,
https://www.facebook.com/sharer/sharer.php?u=https://myexample.com
After share complete, i want to fetch all comments and likes of that post.
Is it returning post_id? so may be we can fetch comments using post id by graph api?
How should i do that in php?

The sharer.php does not return anything. You can only use the Share Dialog if you want to get a Post ID, but:
Only available if the user is logged into your app using Facebook and
has granted publish_actions.
Source: https://developers.facebook.com/docs/sharing/reference/share-dialog#response

Related

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

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

Facebook Graph API: How to get pages liked by people who liked some other page

how can I get pages liked by people who have liked PAGE A.
e.g
https://www.facebook.com/search/100281786832302/likers/pages-liked
here, 100281786832302 is the Page ID of "Amazon India".
If its possible using PHP graph api.
Thanks
That´s not possible at all with the Graph API, i am afraid. The Graph Search is only available on facebook.com - for real users.
With the Graph API, you can only get the Page likes of a user who authorized your App with the user_likes permission. Check out the docs for example code: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/likes

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.

PHP Facebook API: How to retrieve how long I've been friends with someone

I'm curious if it's possible to get the "friendship" information via the Facebook PHP API, meaning information about the friendship the logged in user and one of his friends share?
Information that is visible on this page:
https://www.facebook.com/profile.php?id=[YOUR ID]&and=[YOUR FRIENDS' ID]
Is this possible?
Via the Graph API you can query the /me object. Two properties you will want relationship_status and significant_other. I don't see where it specifies the "how long" part. Not from the Graph API nor from FQL.
Also see me/family in the graph.

Uploading photo to another user's profile in Facebook using PHP

Can you post a photo to the wall of a friend of the logged-in user using the FB Graph API? I could find no posts that answered this exact question but if there are please point me in the right direction.
I have tried the code found in answers to this question to post a photo, but no matter what user id is used in the call to api, the photo gets added to an album on the logged-in user's profile.
Is it possible to post a photo to another user's profile - just like one any user can manually add to someone's Wall Photos? i.e, a post that will have type: "photo" in the graph API instead of type "link".
Even while going through the old publish documentation, they specify you can only include attachments using links to the media you'd like to attach and not by uploading directly through the API. Looks like this is the route you're going to have to go (using the link property you've already mentioned)

Categories