douxuelv7755 2018-11-19 20:51
浏览 32

存储库webhook给了我空的json

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起