无法在Php中分析Zapier REST订阅挂钩

无法在Php中分析Zapier REST订阅挂钩,php,rest,api,zapier,Php,Rest,Api,Zapier,我正在设置一个Zapier订阅钩子,这是它为我测试生成的代码 const options = { url: 'https://www.my-web-site-url.com/zapier/api/subscribe/hook', method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-KEY': bundle.authData.api_key, 'Accept': 'application/json' }, pa

我正在设置一个Zapier订阅钩子,这是它为我测试生成的代码

const options = {
url: 'https://www.my-web-site-url.com/zapier/api/subscribe/hook',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': bundle.authData.api_key,
'Accept': 'application/json'
},
params: {
'api_key': bundle.authData.api_key
},
body: {
'helloWorld': '123123',
'hookUrl': bundle.targetUrl
}
}

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content);

return results;
});
当我在Zapier内部运行测试时,它成功地发布到我的PHP脚本中,但当我尝试解析PHP脚本中的主体变量“hookUrl”或“helloWorld”时,我得到的只是空白(没有任何内容)

以下是我的简单PHP代码:

 echo $_POST['helloWorld']; 

当我看不出为什么$\u POST['helloWorld']不呈现“123123”而不呈现“123123”时,我做错了什么。

$\u POST
数组仅用于内容类型为
应用程序/x-www-form-urlencoded
多部分/表单数据的HTTP-POST请求

我建议获取请求主体,它是一个json编码的字符串,并将其解码为一个数组

$postdata=文件获取内容(“php://input");
$request=json_decode($postdata,1);
echo$request['helloWorld'];

您的POST请求正在发送JSON,因此您需要对其进行解码,因为suchI也尝试过,但没有这样的运气。但我不明白,内容类型不是“application/x-www-form-urlencoded”,而是“application/json”,所以它一定是一个更复杂的问题。。。今天早上,这一切才开始神奇地工作,我的代码没有任何变化#奇怪的