Posting event to facebook using the graph api - facebook-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??

Related

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?

facebook graph api webhook friend not working

I am trying to keep track of my users' facebook friends. I thought that using the webhook is the best solution to this problem.
The webhook is currently working, the request I get from facebook is a json of 2 objects (users), who added each other as friends, so I am able to update them in the database.
For some reason I sometimes get an object of only one user, and I get the other friend in a seperate object. There is no way for me to relate the 2 requests together.
I have read through the whole document but it didn't help https://developers.facebook.com/docs/graph-api/webhooks/v2.5
Is there something that I am doing wrong, or is just using the webhooks for this task is not the right solution? If it's not the solution, should I scrape all my user's facebook friends periodically?

How to read Facebook Insights for a Native/Desktop app programmatically

Unfortunately I'm struggling to understand the documentation provided by Facebook.
This is the scenario:
- Some of my iPhone Apps are also registered as Native/Desktop Apps on Facebook in order to support the Facebook Audience Network.
- I'm building a tool in python which will retrieve data from the reporting API in order to run some automated analysis on specific metrics (request, impressions and so on).
The question is: how do I retrieve this data?
The documentation for the reporting API is here: Reporting API
However I'm struggling with the access token.
It says that I could use the specific App Token available here: App Tokens
However by using such token, I get an error saying that app tokens can't be used for Desktop/Native Ads.
What is the correct way to do it then? Here is where I struggle to understand Facebook Documentation.
My guess is that I should use a User Access Token instead, generated for a user that is also the admin of the App for which I want to retrieve the insights.
What really freaks me out is that apparently, this can't be done with normal HTTP calls only but it requires instead to go through the Facebook Login Dialog. I also need to create another Facebook (web) app because there is no way to get a simple "User Object"... Everything needs to start and go through a registered Facebook App. And there's no way to go through these steps by using backend code only.
So... to recap... in order to read the Insights for a Native/Desktop Facebook App (APP_A), I have to:
- Create a new Web Facebook App (APP_B)
- Create a web interface somewhere for APP_B) which will trigger the Facebook Login Dialog and request the read_insights permission.
- Login through this web interface and generate a User Access Token
- Put this User Access Token in my backend code and run the scripts that retrieve the data provided by the Reporting API for APP_B
Really... to me... it doesn't make any sense to create a new Facebook App in order to access the data of another Facebook App.
Isn't there another better, simpler, quicker, cleaner way to achieve the same final result?

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.

Django and Post to Facebook (no authentication)

OK, I need some help understanding the process behind Facebook's website integration process and how I can integrate it into my web app....
In its most basic form, my site stores and displays users' comments about products (there's more to it than that, but that's all that's relevant for this question). What I'd like to do is allow them to post that comment, together with the name of the product (and my site), to their Facebook wall by clicking a button.
I do not need the users to log in to my site at all, either with Facebook or any other authentication system and the Post to Facebook part is optional.
Obviously if they decide they do want to post their comment to Facebook, then they'll need to login, but I'd rather temporarily take them away from the page to login, post and then be brought back to my site.
What I need to know is how much of Facebook's APIs, Open Graph and Auth systems do I actually need to integrate?
I had hoped that I might be able to generate a simple link to Facebook with their comment embedded as a POST element...?
I'd be really grateful if someone could point me in the right direction!!
(P.S. I need a similar solution for Twitter, but I think that's easier!?!)
The Feed Dialog doesn’t allow including of a pre-set message any more, so you’d have to make that post via the Graph API if you want to pre-fill the message (and even then, you should only do so, if you’ve given the user the possibility to edit the pre-filled message first).
See here for how to make a post on a user’s behalf via Graph API, https://developers.facebook.com/docs/reference/api/user/#posts
You can do that all client-side, if you embed the JavaScript SDK into your page.
You need to set up an app on FB, then have the user connect to it (using FB.login), ask for the necessary permission (publish_stream) while doing so, and after successful login use FB.api to make the Graph API call.