Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php://input always empty #6

Closed
h2u opened this issue Apr 17, 2016 · 6 comments
Closed

php://input always empty #6

h2u opened this issue Apr 17, 2016 · 6 comments

Comments

@h2u
Copy link

h2u commented Apr 17, 2016

Not sure that it's your package problem but i have nothing in $data variable (json_decode(file_get_contents("php://input"), true)).
Can't find any soultion about this.

Im writing data to file like (file_put_contents('bot_'.time().'.txt', print_r($data, true));) this and file is empty.

Can you please help me?

@ya-kostik
Copy link

ya-kostik commented Apr 18, 2016

Try to log file_get_contents("php://input") without json_decode

Can you get some samples of your code with this problem?

P. S. GET or DELETE methods doesn't have body, and php://input will be empty

@h2u
Copy link
Author

h2u commented Apr 18, 2016

<?php
if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] == 'subscribe' && $_REQUEST['hub_verify_token'] == "<mytoken>") {
    echo $_REQUEST['hub_challenge'];
} else {
    $data = json_decode(file_get_contents("php://input"), true);
    file_put_contents('bot_'.time().'.txt', print_r($data, true));
}
?>

The first part of code needs only to verify webhook.
I think Facebook sends PUT method to webhook.
I can't access ftp now, so I will try to write "php://input" to file later today and give you answer, @ya-kostik.

@maxpinyugin
Copy link
Member

Please, check web server logs.
php://input not getting through if request has an redirection.
Maybe your webserver has an redirect from www. to url without www or maybe without slash on wnd of address to without slash.

@h2u
Copy link
Author

h2u commented Apr 18, 2016

Thank you guys.
@ipimax you were right. I had url like https://domain.com/bot, and it has redirect to /bot/ (added slash).

So I changed url and it's ok now.

@h2u h2u closed this as completed Apr 18, 2016
@manix
Copy link

manix commented Jul 8, 2018

Just ran into a similar issue, worth mentioning that the app won't get any data if it's not public, not even for admins.

image

@o2-web
Copy link
Contributor

o2-web commented Jul 8, 2018

@manix You need to pass app review include business verification (if needed)

this is a separate topic for discussion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants