Facebook not giving useful information in webhook - facebook-graph-api

I have implemented Facebook webhook successfully by https://developers.facebook.com/docs/graph-api/webhooks/
I have subscribed to But it is missing useful information, It gives me following response
The JSON is for example:
{
"object":"user",
"entry":[{
"uid":"1408932149",
"id":"1408932149",
"time":1370253930,
"changed_fields":["feed"]
}]
}
But I want to track what actions happen on user's post which posted by my application. Here on every action it gives me feed in changed_fields. Its pretty useless for me
Basically I want to track like, comment and share of the posts for users in real time which shared from my software/app. I have subscribed to this reference https://developers.facebook.com/docs/graph-api/webhooks/reference/user/
I know for page it is working through webhook but how can I track user's post data with the webhook?
Can anyone suggest where I am doing wrong?

Related

messages API twitter Challenge-Response Checks

I've seen that twitter changed their endpoints to get and send direct messages, I noticed from a reply from here that it is a workaround to be able to send messages with well-known libraries such as tweepy, but all I need in this case is to list the messages in my inbox.
I've noticed that there is an account activity api which I can use to achieve this goal.
But, I do not understand how to implement Challenge-Response Checks, can you provide an example? how twitter checks this? it is through a post request to my site? to what specific URI they do this? I tried sending a pipedream url as webhook (to see what kind of request they were doing, but absolutely no request was shown)
The account activity endpoint is part of Twitter's Premium product - so you may need to pay to use it. They have comprehensive documentation on the CRC - that includes a sample Python implementation.
I think you will find it easier to use to use the GET direct_messages/events/list API call.
That will list all of the messages in your inbox for the last 30 days.

Communicating over Messenger on behalf of another user's page

I want to make a Messenger bot with Messenger platform. But this bot needs to be connected to other Facebook users' pages, not my own page. I have a Facebook app with Messenger configured. I want to let other Facebook users who are page owners to give my application a permission to post on behalf of their pages through Messenger, as well as receive messages from their pages on my app's webhook.
The Messenger Platform docs only explain how to post on behalf of your own page.
Is is possible to make this through Graph API + Messenger Platform or something else? And maybe with a few pointers how?
This is how I send my messages:
uri: 'https://graph.facebook.com/v2.6/me/messages',
qs: { access_token: PAGE_ACCESS_TOKEN },
method: 'POST',
json: messageData
So I think if you would just need them to supply you with their page access token, and then you could send messages as their page through your bot.
EDIT: I guess this only answers how to send messages as them. To receive messages too you'd need to somehow subscribe your webhook to their page, which I think you need to be an admin of to do, so I'm not sure receiving their pages messages is possible through a straightforward system like what I'm suggesting. There may be other more complex workarounds though.
EDIT2: Maybe you can give them your webhook URL and have them verify and subscribe it for you

How to programmatically post like and comment an URL on facebook?

This is confusing. So just to clarify:
REQ #1: To fetch basic stats for a URL, you send GET request to:
http://graph.facebook.com/?ids=http://some.com
(alternatively, FQL can be used to fetch stats for a URL, but that doesn't return the OpenGraph Object)
REQ #2: To fetch comments for a URL, you do a GET:
http://graph.facebook.com/comments/?ids=http://some.com
REQ #3: To fetch likes for a URL, you GET:
http://graph.facebook.com/likes/?ids=http://some.com
But how do you comment on / like a URL programmatically?
I guess, likes can be created using Open Graph API, right?
https://graph.facebook.com/me/og.likes?object=1234
where 1234 is the OpenGraph Object ID of an article (as returned by REQ #1).
But this requires an approval process, the like action has to be approved by Facebook.
Is there a better way to do this? Can I use for example the Graph API for all these things?
My goal:
Currently I'm using the Facebook like button and comments plugin to create likes and comments. But these use the JS SDK, which is huge, and they generate a lot of external requests. I wanna get rid of them and just send an AJAX request to my server, which would then asynchronously talk to Facebook, and it would post the Like / Comment.
Is this possible?
Thanks in advance!
I read through the Facebook docs briefly and I don't believe you can do this other than the way you indicated with authenticating.
You should also take a look at this thread: 'Like' a page using Facebook Graph API
You would need to authorize every single user before he would be able to like something, and you would need to go through a review process on Facebook. And i am pretty sure you would not get the required permissions approved just because you want to get rid of the JavaScript SDK overhead, to be honest.
The Social Plugins are asynchronously, so the overhead for downloading the SDK is irrelevant as it happens in the background and it is non-blocking.
I have an idea, to do this. You can use long term access token, Once you login you receive short term token. After receiving short term token you need to request your long term access token. Save that token in DB or file.
Then you can use Graph Api, to make requests. This will eliminate the need for access requirement every time you request api.
Just use access token you saved before.
Refer this documentation from Facebook for further clarity.
https://developers.facebook.com/docs/facebook-login/access-tokens
Happy Coding!
Atul Jindal

How to edit an existing event using the Facebook Graph API

I've done extensive research on this, and am baffled. Similar questions on stackoverflow have been answered with, in in short: RTFM. Well, I've done that, and more, and I still can't find how to do this.
On the main FB Graph API page, documentation is given for authenticating, reading, publishing (creating), deleting Graph objects, but I don't see modifying anywhere.
The FB Graph API > User page gives description only of how to create and delete an event on behalf of an authenticated user. I've had no problem with these two actions.
The FB Graph API > Event tells you how to retrieve an existing event, as well as publish to the existing event, posts, links, feed, etc. Once again, no help with modifying.
I've tried (desperately) (':'s removed intentionally due to hyperlink limit):
Sending the same POST request as creating event, ie to https//graph.facebook.com/<user_id>/events, but with an extra 'id' parameter--the existing facebook event id. Facebook doesn't like that, gives me an 'id parameter already sent' error (I'm assuming the user's id).
POSTing to the event directly ie to https//graph.facebook.com/<fb_event_id>/ using the same auth_token as was used to create it. 'Post unsupported' error message.
The fields I send along with the POST are the same as those when creating the event-- 'name', 'location' etc.
If someone's been able to do this, one simple POST example would clear everything up for me.
Thanks!
UPDATE I started using the PHP SDK, but lack of examples disheartening. In hopes that this will save someone else frustration Here are doc examples augmented with an actual api call example:
"You can create an event for a user by issuing an HTTP POST request to
PROFILE_ID/events with the create_event permissions and the following
parameters."
$facebook->api('/'.$profile_id.'/events', 'POST', $params);
Normal enough ... but edit event docs (as of 12/7/12) are misleading:
"You can edit an event by issuing an HTTP POST to /EVENT_ID with the
create_event permission. "
$facebook->api('/events/'.$eventid, 'POST', $params);
Brian
I was able to update a page event by using a POST (not a PUT) directly to the event, using the account or page authentication token. It sounds exactly like what you did in 2 above.
curl -F 'access_token=...' \
-F 'name=A modified event name.' \
https://graph.facebook.com/event_id
I would suggest that you try just sending a modified name field. Also, because you have already created the event, you have the correct permissions. For those who don't know, you need the extended permissions of offline_access, create_event, manage_pages, etc.
It is frustrating, because at one time there was documentation on updates on the Facebook site, but now I can't find it.
Updating is the same as creating BUT, you can only update events created by your APP ID..

Facebook API Graph - posting a status update to a Facebook Page

I am following the Facebook developer documentation for making a post to a Facebook 'Page' as the Page itself, which according to the docs requires impersonation. I've gotten the access token for the page itself, as well as the Page's ID, by making a call to the "accounts" feed for the user who's the admin for the Page. I then POST to
https://graph.facebook.com/[Page_ID]/feed
With the post items
access_token
and
message
containing the access token and the message, and I get a JSON string back with a post ID. Which all seems to indicate that it is posting the message to the page. HOWEVER, when I go to the particular Page, it doesn't display the posted status.
Does anyone perhaps have any idea why that might be?
Thanks in advance everyone!
Did you make sure to get the "publish_stream" permission from the user?
http://developers.facebook.com/docs/authentication/permissions