简体   繁体   English

php-从hipmob接收webhook数据

[英]php - Receive webhook data from hipmob

I'm trying to receive a webhook from hipmob (live chat app) that should be triggered at a chat event. 我正在尝试从hipmob(实时聊天应用程序)接收一个Webhook,该聊天应在聊天事件中触发。

Documentation: https://www.hipmob.com/documentation/chat-events.html 说明文件: https : //www.hipmob.com/documentation/chat-events.html

I've been following How to catch the HTTP POST request sent by a Shopify Webhook , and i have to say that i am completly new to this. 我一直在关注如何捕获Shopify Webhook发送的HTTP POST请求 ,我不得不说我对此是完全陌生的 I tried the solution from the first answer but with no success. 我从第一个答案尝试了解决方案,但没有成功。

this is what i did: 这就是我所做的:

<?php
$webhookContent = "";

$webhook = fopen('php://input' , 'rb');
while (!feof($webhook)) {
    $webhookContent .= fread($webhook, 4096);
}
fclose($webhook);

$file = 'webhook.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
// Write the contents back to the file
file_put_contents($file, $current);

error_log($webhookContent);
?>

but with no success 但没有成功

I was able to solution it with: 我能够用以下方法解决它:

   <?php

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

    $file = 'webhook.txt';
    // Open the file to get existing content
    $current = file_get_contents($file);
    // Append a new person to the file
    // Write the contents back to the file
    file_put_contents($file, $entityBody);

    error_log($webhookContent);
    ?>

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

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