php - Bitbucket webhook 不发送负载

标签 php git bitbucket webhooks

我是 webhook 的新手,每当我推送到我的存储库时,我都会尝试自动部署到我的网站。

我在我的 bitbucket 存储库上将 webhook 设置为一个包含简单 php 脚本的 URL:

if(isset($_POST['payload'])) {
    logMsg("Got stuff\n");
} else {
    logMsg("No stuff\n");
}

在我推送到我的 repo 后,webhook 将请求脚本正常但没有发送有效负载。我的日志文件总是显示“No stuff”。

我错过了什么?

最佳答案

新的 Bitbucket webhooks 在请求 body 中发送有效负载,而不是像以前的“服务”那样在请求 header 中发送。 因此,要访问有效负载,您必须像这样阅读请求正文:

$payload = file_get_contents('php://input');

或者像那样:

$payload = stream_get_contents(STDIN);

瞧瞧!

关于php - Bitbucket webhook 不发送负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33315767/

相关文章:

git - url 中的 Bitbucket 凭据

php - 按最新时间戳选择

git - 如何在 git 硬重置后恢复上次提交?

git - 恢复无效的 git merge

git - 正确使用git

windows - 使用 cygwin 的 Git 存储 https 密码

php - 如何通过 .htaccess 在 404 错误重定向中传递查询字符串?

php - SQL语句/Codeigniter预约

php - 如何显示上周的项目?

php - 从 BitBucket 请求 OAuth token