Subscribe to facebook graph api webhook for website likes count change - facebook-graph-api

I have a website with some posts that have facebook like buttons. I would like to be able to sort those posts based on fb like count.
I can get number of likes for any post querying https://graph.facebook.com/?ids=ABSOLUTE_URL_TO_POST but I would like to be able to subscribe to Graph Api, so endpoint of my server can get notified whenever someones likes any of those posts.
That way I could store number of likes in my DB and then be able to sort posts based on that.
However, I am not able to find any suitable event in FB Graph API that I could subscribe to.
Any ideas? Thanks!

As correctly pointed out by luschn, there is no webhook api for getting likes count. Also if you will try get this likes count by polling graph.facebook.com you will quickly hit limit of allowed requests by facebook.
There is no way how to do this at the moment.

Related

Posting event to facebook using the graph api

I am trying to build an application where admin users would trough a form insert "events" containing title, description, starttime/endtime and some other fields. At the moment theese users are primarily using facebook to reach out to their users, they would like to be able to move to my app aswell as stay on facebook without too much hassle. I solved the issue of getting the events of facebook by having them all sign up for the graph api with their community/company pages and giving me the access token to fetch data about their events trough a get request to.
https://graph.facebook.com/v15.0/me/events?access_token={their token}
Now my next task at hand was simple i tought simply make a post request to the same api endpoint, but i quickly realized i was not able to do this and well i do not know how to proceed to be fair.
Tried to make a post to the same endpoint but got errors and after searching the documentation found that this was not supported??

Realtime Updates from FB API

I have a working Azure function that receives updates when I use the Graph API Explorer.
All I want to be able to do is submit a UserId to an endpoint and have any Posts they make sent to my WebHooks. We want to do this without the users always having to give permission. Unfortunately, I find the FB docs very confusing as most pages only have partial examples and the majority of the online SO or blog examples are far out of date.
On the FB WebHooks page it says
For example, if you subscribed to the user object's photos field and one of your app's Users posted a Photo, we would send you a POST request that would look something like this
They then say
You can also do this programmatically by using the /{app-id}/subscriptions endpoint for all Webhooks
On the Subscriptions page they have this example
POST /v12.0/{app-id}/subscriptions HTTP/1.1
object=page&callback_url=http%3A%2F%2Fexample.com%2Fcallback%2F&fields=about%2C+picture&include_values=true&verify_token=thisisaverifystring
But then its says this under Permissions
Subscriptions for the object type user will only be valid for users
who have installed the app.
This is not for a mobile app..so I'm confused
The above is to show that I have made all attempts to get this working without first posting here.
Now, I have to ask. Do anyone have experience or a existing code that demonstrates how to Subscribe to a User so that when they Post, I receive Notifications via webhooks?
Or, this this entirely the wrong way to use the Webhooks?

Get like_count & comments_count for specific media with Facebook Instagram API business_discovery

I would like to update the like_count and comments_count for a specific instagram post with the new Facebook Instagram API. We have the post id and other data stored in our database and would only need the data of that specific post. At this point I am able to get the like and comment count via this API call:
https://graph.facebook.com/v2.12/xxxx?fields=business_discovery.username(jacqehoward){id,name,username,website,profile_picture_url,biography,followers_count,media_count,media.after(QVFIUlZA5aTR5NTE4Y24tNW90VGZAPTVBtb0NpOEFPTlNLeklmVTEtUDZAfVnE0YnBhUVNOQ3BDaktzNHJBTENhTmVYLUV2SGJPZAVAxZA09hQ2NhUGdnUGFjMTNn){id,caption,comments_count,like_count,media_type,media_url,owner,timestamp}}
After a while new posts are added to the account and you would need to go through all of the posts to find them again and to be able to get the like & comments count. In the old Instagram API you could get like and comment count per media. In the new Instagram API you are only able to get reach or "engagement" which is a combination of likes and comments while I want to have them separately.
https://developers.facebook.com/docs/instagram-api/insights
Anyone who has an idea how to add like count and comments count to the insight endpoint call?
Second question: If an instagram user with a private instagram account connects with your app how do you get the Facebook instagram ID so you can collect the posts on their timeline?

How to get Facebook page posts count on Android using Facebook SDK

I am building an app, which lists all posts from a Page(that I manage and post to) and also gets corresponding posts view count. I looked into the documentation and it seems like the page needs a minimum of 30 Likes for insights API to work. Is this correct? Is there a way I can get the view count?
Here is the output from Graph Explorer. I have set the access token to Page Access token.
I am passing the Post_ID to HTTP GET. I can see directly from Facebook that the post has reached N number of people. But the returned data from the API call is empty. Any help?

Facebook OpenGraph: Getting like count of post without User Token

I have an existing app that uses the Facebook API & login that makes posts to the user's wall. For each post I store the id of that post.
What I need to accomplish is to gather like counts of those posts generated by the first app. I'm trying to write a small app that routinely pulls the like count. I've figured out how to get the like count of the post if I use a User Token - via Facebook Login. But since this app will run as a batch and not by a human, I don't want to use a Facebook login page. I could write code that simulates a user logging in but that would be a major ugly hack. I've tried to use an App Token but then the like count is always zero. I've found how to get the like count of a page without the need for a User Token http://www.techrecite.com/get-facebook-likes-count-of-a-page-using-graph-api/ but not a post
Is this even possible? If so how?
I've looked into Facebook API's subscription, but it doesn't seem possible to subscribe to a "like-a-post" event. Although I could be wrong. If so, could someone point me in the correct direction.
Thanks.