How to get who and when a user shared a Facebook post - facebook

For my Facebook posts my friends share (not likes) I would like get who shared it and when. Using the graph api I can get the like or comment information and the number of times a post has been shared.
What I am looking for is a graph api call or Facebook fql query for shares which returns a result set similar to this:
data": [
{
"id": "user_id_1",
"name": "Username 1",
"created": "some date"
},
{
"id": "user_id_2",
"name": "Username 2",
"created": "some other date"
}
]

I am also looking for the exact thing for long time now. Since Facebook shows the list of users who shared the post, I was expecting that the same will be available in Graph API. But unfortunately nothing such exists till date.
The best workaround I could find for this problem is scraping the Facebook page for the list of users who shared the given post. I haven't yet tried this solution but this should solve the problem for now. The only issue here is, if Facebook changes the HTML structure of that page, the scraper will have to modified.

Related

Retreiving facebook comments by API

I would like to maintain a copy of all Facebook comments on my business page for analysis purposes.
I created an app and tokens and managed to query all posts on the page by this call
https://graph.facebook.com/v11.0/{page-id}/feed?access_token={token}
And for every post I can get the full comments by this call:
https://graph.facebook.com/v11.0/{object-id}/comments?summary=1&filter=stream&order=reverse_chronological&access_token={token}
That worked great but I have two problems:
I would like to retrieve all new comments on all posts. My page has 500+ posts. It would be very wasteful to query each of the 500 pages on daily basis to get all comments because 490+ of them will probably have no new comments on an any given day.
The results from the comment API call is very basis and does not provide the user name like the below sample
{
"data": [
{
"created_time": "2021-06-10T23:52:09+0000",
"message": "test 3",
"id": "xxxx_xxxx"
},
Is there a way to retrieve all comments regardless of the page and provide more info in the result? There are commercial tools that perform similar functionality like Sudota so theoritcally it should be possible but I could not find that in the API documentation.

Get All Posts from Facebook Page

I am looking for the information posted on the facebook page. I am able to hit the api as below https://graph.facebook.com/v2.8/203511053776284/feed?limit=100&access_token=XXXXXXXXXXX&format=json. I am able to get the below data but no images related with post.
data": [
{
"message": "This is my first post",
"created_time": "2018-05-16T08:05:02+0000",
"id": "203511053776284_203511440442912"
}
]
Any way to get all the information from facebook page.
You need to pass fields value to fetch additional data.
https://graph.facebook.com/v2.8/203511053776284/feed?fields=id,name,message,story,created_time,link,description,caption,attachments{media,type,subattachments}&limit=100&access_token=XXXXXXXXXXX&format=json.
I recommend exploring Graph API Explorer tool.

How to get Facebook Insights data of photo feed using Graph API?

Insights API works properly for link feed but it doesn't work for photo feed. For photo feed, Insights API returns 0 or empty even though Insights page shows a high reach and engagement rate.
Here is the url pattern of my photo feed:
https://www.facebook.com/[PAGE]/photos/a.xxx.xxx.[PAGE ID]/[POST ID]/
Insights API returns:
{
"id": "[PAGE ID]_[POST ID]/insights/post_story_adds_by_action_type_unique/lifetime",
"name": "post_story_adds_by_action_type_unique",
"period": "lifetime",
"values": [
{
"value": [
]
}
],
"title": "Lifetime Talking About This (Post) by action type",
"description": "Lifetime: The number of unique people who created a story about your Page post by interacting with it. (Unique Users)"
}
I've been struggeling with the same questions... one thing I can tell you is, that you most likely used a wrong id for you photo post.
Please ensure that you ONLY use ID's retrieved by a facebook api. So this is a sample process:
1. Note your page-id
2. Use GRAPH to query <url-to-graph>/<page_id>/feed?access_token=<your_token>
3. From the response, take the photo-post-id you want to analyze
4. Use GRAPH to query <url-to-graph>/<id_from_step_3>/insights/?access_token=<your_token>
5. Check the metrics returned from step 4 and enjoy!
Please keep in mind that there's an undocumented need to add your page_id to any post_id. So every replacement of {post-id} as it is written in the FB api's will be _.
Hope that helps...

Displaying Different Copy / Images Based on the Number of Likes

We're working on developing a program that will (hopefully) automatically swap out creative with new creative once a certain like threshold is met (i.e. if 100 people like the page, something new appears). Can we add coding so our system is able to tell how many "likes" are generated? I know that the number of likes are displayed, I'm just not sure if there is a way for a program to actually read how many likes there are.
I don't see if in any of the Facebook attributes in the developer's platform.
What you'll have to do is acquire an access token for your page and then query the facebook platform for the number of likes periodically (possibly with a cron job of sorts).
You can read more about how to get the page access token at this URL
https://developers.facebook.com/docs/authentication/
Facebook has given us a great took to help us mine all the data it holds - its called the Graph API Explorer and with it you can see what data will be returned when you query the API. When you query the API with only the page_id you'll get a response similar to this :
{
"id": "XXXXXXXXX",
"name": "My Awesome Page",
"picture": "foo.jpg",
"link": "https://www.facebook.com/pages/XXXXXXXX",
"likes": 345,
"category": "Product/service",
"website": "XXXXXXX",
"founded": "2011",
"description": "...",
}
For more information about how to use the Graph API you can see this link :
https://developers.facebook.com/docs/reference/api/
Facebook does provide good documentation:
http://developers.facebook.com/docs/reference/api/page/
As you can see there, there is a field "likes" containing the number (count) of likes for a page.

Getting the last date user clicked like on anything on Facebook

I'm developing an app on facebook and want to get the last date that the user of my app liked anything on Facebook.
It doesn't matter if its a page, post, comment, link or anything else you can like on Facebook.
Is it possible?
Thanks!
Actually, you can. (Probably added since Peter Bailey wrote his answer.)
Each like has a created_time field. The likes connection of a user object in the graph API returns most recently liked objects first. So if you just fetch the most recently liked item and check its creation time, you can get this data.
The API GET call would be:
/me/likes?limit=1
and the result would look like:
{
"data": [
{
"name": "Steve Jobs",
"category": "Business person",
"id": "113529011990795",
"created_time": "2011-09-23T02:22:22+0000"
}
],
}
You can play with this on the Graph API Explorer.
No.
A timestamp or other type of date value is not part of the information retrievable for likes. Not through FQL nor through the Graph API.