简体   繁体   English

如何从执行的 webhook 中获取数据?

[英]How to get the data from the executed webhook?

Hey guys?大家好? can someone help me, I'm new to php and I'm trying to receive the data from the webhook.有人可以帮助我吗,我是 php 的新手,我正在尝试从 webhook 接收数据。 so I created a survey in gohighlevel and what I'm trying to accomplish is that I need to receive the data from the survey when the webhook is triggered.所以我在 gohighlevel 中创建了一个调查,我想要完成的是我需要在触发 webhook 时从调查中接收数据。

I'm using gohighlevel for the survey and execution of webhook.我正在使用 gohighlevel 进行webhook 的调查和执行。

I put the test server as the webhook url and in my test server, this is the code.我将测试服务器作为 webhook url 在我的测试服务器中,这是代码。

<?php
    if($json = json_decode(file_get_contents("php://input"), true)) {
        print_r($json);
        $data = $json;
    } else {
        print_r($_GET);
        $data = $_GET;
    }
?>

And the result is just empty array.结果只是空数组。

Array()

What am I doing wrong here?我在这里做错了什么? please help.请帮忙。

edited: replaced $_POST to $_GET, I accidentally put post instead of get.编辑:将 $_POST 替换为 $_GET,我不小心把帖子而不是 get。

From the picture it looks like they're querystring parameters, so you'll most likely find them in $_GET rather than $_POST .从图片看起来它们是查询字符串参数,因此您很可能会在$_GET而不是$_POST中找到它们。 They certainly aren't being sent as JSON.它们肯定不会以 JSON 的形式发送。

eg例如

$firstname = $_GET["firstname"];
$lastname = $_GET["lastname"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM