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.
Related
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.
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...
I'm building a voting application on my new website, cabinethardware.org. I'd like the voting to be done in such a way that when someone votes for a project (to receive a $1000 rebuilding grant) that they are encouraged to plug the project via social networks. My programmer has had difficulty with the application, and it occurred to me that one way of doing it is to just put like, tweet and G+ buttons on the site and add them together. So if a project gets 24 likes, 12 tweets, and 18 G+, it would have 64 votes. It doesn't bother me if someone votes on all three engines.
Before a project is eligible for a grant, it must receive 100 votes. My question is, is there a way that I can aggregate the likes, tweets, and G+ so that I can see on the backend how many votes each project has, without going to each project and adding them up by hand? Also, I'd like to display to customers the combined total.
Does anyone know of a way to combine the count of these three?
For Google+, you would only need to perform one API call to the Google+ APIs that would be searching the Google+ public data. Searching the Google+ public data is demonstrated in the API explorer.
The post response contains information about reshares and +1s:
"verb": "post",
"object": {
"objectType": "note",
"content": "Setting up a server-side flow project that accesses Google+ data using the .NET stack can be a little tricky, I walk you through it in this blog post.",
"url": "https://plus.google.com/109716647623830091721/posts/g8LjdGAXdDc",
"replies": {
"totalItems": 0,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/comments"
},
"plusoners": {
"totalItems": 6,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/people/plusoners"
},
"resharers": {
"totalItems": 0,
"selfLink": "https://www.googleapis.com/plus/v1/activities/z125srm50lf1slxrd04cfftatqyoglnoqio/people/resharers"
},
For Facebook, you can use the Pages API to count likes for your page, you can experiment with this in their API explorer.
The following data shows their response data:
{
"about": "Build and distribute amazing social apps on Facebook. https://developers.facebook.com/ ",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook, mobile, and the web.\n\n",
"is_published": true,
"talking_about_count": 39241,
"username": "FacebookDevelopers",
"website": "http://developers.facebook.com",
"were_here_count": 0,
"category": "Product/service",
"id": "19292868552",
"name": "Facebook Developers",
"link": "https://www.facebook.com/FacebookDevelopers",
"likes": 952596,
"cover": {
"cover_id": "10151121467948553",
"source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash4/s720x720/299374_10151121467948553_45631061_n.png",
"offset_y": 0
}
}
Likes are just a member in the response data.
For twitter, you can query for mentions of a user with their search API and passing a search string for the user as #user. A count of the objects within results is going to be your mention count. The response data is a little too much to paste in here but here's an example query using their API.
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.
Given a facebook url such as http://facebook.com/cnn, is there any way to get the ID of that page short of scraping it?
It is better (and legal) to do this with graph API. Just perform API request to https://graph.facebook.com/cnn and get id from the response.
Here is the response for cnn:
{
"id": "5550296508",
"name": "CNN",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs178.ash2/41813_5550296508_728_s.jpg",
"link": "http://www.facebook.com/cnn",
"category": "Company",
"website": "www.cnn.com\nwww.ireport.com\n",
"username": "cnn",
"company_overview": "TRIVIA FROM THE CNN TOUR...",
"products": "CNN US...",
"likes": 1689936
}
Facebook's own Graph API supports it. From the documentation:
The "ids" query parameter also accepts URLs. This is useful for
finding IDs of URLs in the Open Graph. For example:
https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
As of Today(28th July 2015), There still exists an easy way to get page(or user's) id.
Browse to facebook page(or user) url. The syntax is https://www.facebook.com/[username or pagename]
Right click to view source and then search for string "pageID": in case of page. The numeric id next to searched string will be id.
In case of user, search for "uid":.
Been working with it today. So, for people who want to know how this works. Use this:
https://graph.facebook.com/<the_fb-address>?access_token=$accessToken
And remember: this is only for pages. Not user pages/friends' timelines etc.
Those will have to approve your Facebook App first before you can read their profiles.