Pipedrive Webhook PHP 端点代码示例

Pipedrive Webhook PHP endpoint code example

我已经从 Pipedrive 设置了一个 webhook 来激活正在更新的交易。我正在努力寻找正确的方法来阅读 php 中的 json 响应。我是 Webhooks 的新手,所以还有另一种读取响应数据的方法吗?这是我的:

    <?php
    $result = $_REQUEST['current'];  // this is where it is not working I believe
    $obj = json_decode($result, true);
    $txt = $obj['id']
    $myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
    fwrite($myfile, $txt);
    fclose($myfile);

在 requestbin 中,我收到了包含我期望的所有正确信息的响应

事件主体似乎包含一个名为“current”的数组,其中包含所有相关数据,我想提取“id”以查看它是否正常工作

    "body": {
           "current": {
            "id": 71}

非常感谢任何帮助

我找到了一个答案,向我展示了我所需要的

$result = file_get_contents("php://input");

这会从显示数据的服务器中拉回完整的响应