I'm trying to connect my repository to a php file, hosted in a free web server, with a webhook.
The problem is that I don't receive any data.
This is my webhook.php file.
<?php
$data = file_get_contents('php://input');
$data = json_decode($data, true);
print_r($data);
And these are request and response headers details from Github:
Request Headers
Request URL: http://<user>.<domain>.org/webhook.php
Request method: POST
content-type: application/json
Expect:
User-Agent: GitHub-Hookshot/8f0ea18
X-GitHub-Delivery: 45e2783a-ec35-11e8-8444-a0221ee402c8
X-GitHub-Event: push
Response Headers
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 841
Content-Type: text/html
Date: Mon, 19 Nov 2018 19:55:35 GMT
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Server: nginx
Vary: Accept-Encoding
The response is a 200
http status.
I've tried with others repository (Bitbucket and Gitlab) but I always receive an empty json data. In particular, with Bitbucket, I've ticked off the option Skip certificate verification
but without any positive result.
Thanks
Edit 1
<?php
$data = file_get_contents('php://input');
if (empty($data)) {
echo 'empty';
}
else {
echo strlen($data);
}
$data = json_decode($data, true);
print_r($data);
returns empty
even if response headers' content-length is not 0
.