Weird thing is happening, I have registered my webhook and setup up everything, but now I am not receiving POST requests anymore when I am talking to my bot. FB only sends me GET requests to the webhook when I send a message.
Does anybody have an idea what the problem could be and how I can look for a solution?
Thanks in advance!
Re-authenticate your page.
curl -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=<ACCESS_TOKEN>
I was having the same issue and spent a lot of hours banging my head on the wall before I found this:
yii2 Webhook post empty
Not sure if its the same problem the OP had, but I think is usefull to leave it here anyway: the hook was being called with POST, not get, and the data was being sent, but PHP does not receives it on the $_POST, and so it looked like a GET (because Yii::$app->request->post() returns false). But then I logged $_SERVER and it was actually a POST request, except $_POST was empty. Then I found that answer
To retrieve the data facebook sends on PHP, you need either have to use
$data = file_get_contents("php://input")
or, if you use the Yii framework:
$data = json_decode(Yii::$app->request->getRawBody());
Related
G'day all,
Does anyone have any experience with the Waterlock flow for passsword resets? I've hit a wall which I can see a work-around for, but it seems really in-elegant, so I'm probably missing something.
When I send through an auth/reset POST with an email element, the system proceeds to shoot the email out as planned.
When I then submit the received link in a POST request, with a password element, I see a "404" response.
HOWEVER
If I submit that link as a GET request first, and then submit the POST it works.
When I look into the waterlock-local-auth source, the reset POST action is testing for the presence of a decrypted token in the request object before allowing it to proceed.
SO
Either I code my front end to send a get request (which doesn't respond properly) and then resubmit as a POST, or I go in and hack the waterlock-local-auth code to include a decode of the token (which is what I'm thinking is the most elegant solution).
Any clues?
Thanks,
Andy
I have got a similar problem, but I use angularjs as my frontend. This discussion thread is very helpful:
https://github.com/waterlock/waterlock-local-auth/issues/7
Basically, you are expected to submit a GET request to the url received in the password reset email. After you click the link with the token, you will find in your database that a new ResetToken record has been created and the value in the token column is exactly the one you see in the url. Then you should be redirected to the forwardUrl in waterlock.js setting, where there should be a form or anything that can make you post to:
http://yourdomain.com/auth/reset?password=newpassword
Then the password is reset and the ResetToken record will be removed from your database.
If you look at the handlePost function here:
https://github.com/waterlock/waterlock-local-auth/blob/master/lib/controllers/actions/reset.js#L68
This can explain why POSTing to the url sent to you in the reset password email returns 404. The resetToken must exist in session already in order that issuePasswordReset to be invoked. And the only place to set req.session.resetToken is within validateToken method:
https://github.com/waterlock/waterlock-local-auth/blob/master/lib/controllers/actions/reset.js#L188
So you need a get request first. Hope this helps.
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
I am trying to use Facebook's Real Time API with my app. I am not receiving POSTS to my callback url. Some relevant info:
-- I can add/modify subscriptions using the callback URL, so the URL itself is not the problem.
-- I have granted my app all the right permissions
-- I have deliberately included an error at the very beginning of the function that handles POSTs to the callback URL. Yet, I am not getting errors from the function.
From all this, I can only conclude that Facebook is not POSTing to my callback URL. Does anyone have any ideas what else might be going on?
Also, is there any record of Facebook's attempted POSTs to my callback URL?
I figured out what was wrong. The callback URL I gave to facebook did not have a trailing slash, but the url I specified for my handler function did. In Django, by default, if a request does not match anything from urls.py, it will redirect to the same url with a trailing slash appended. However, POST data is lost in this process, and facebook was trying to POST. I figured this out by manually issuing a POST request to my callback URL, using cURL, at which point Django gave me a very helpful error saying all this.
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..
I am looking into authenticating via google.
I dont understand how it works:http://code.google.com/apis/accounts/docs/OpenID.html#Samples
If i do that 2nd request by entering the data as one url with params into browser i get back XML file. Should i not get back sample response nr3?
Can somebody explain this to me?
The problem is, that im trying to sort through some third party app that uses google openid authentication and its not recieving authenticated users e-mail back, like in sample response 3.
Alan
PS i have read through similar questions and their responses and gone through pages like:
How does OpenID authentication work?
http://www.windley.com/archives/2006/04/how_does_openid.shtml
http://tinisles.blogspot.com/2008/02/how-does-openid-work.html
http://openid.net/pres/protocolflow-1.1.png
What sort of XML file?
Remember that a checkid_setup request like that isn't something your application is meant to make with a direct connection, it's a request that's sent from the user's browser. So the response is going to be something for the browser to parse, prompt the user to log in if necessary, maybe ask the user for permission or which values it should send back, and only after all of that send back a redirect like in the sample response.