【问题标题】:php - Receive webhook data from hipmobphp - 从 hipmob 接收 webhook 数据
【发布时间】:2015-08-27 04:39:14
【问题描述】:

我正在尝试从 hipmob(实时聊天应用)接收一个应该在聊天事件中触发的 webhook。

文档:https://www.hipmob.com/documentation/chat-events.html

我一直在关注How to catch the HTTP POST request sent by a Shopify Webhook,我不得不说我对此完全陌生。我尝试了第一个答案的解决方案,但没有成功。

这就是我所做的:

<?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);
?>

但没有成功

【问题讨论】:

    标签: php post request


    【解决方案1】:

    我能够解决它:

       <?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);
        ?>
    

    【讨论】:

      猜你喜欢
      • 2018-08-18
      • 2016-05-19
      • 2021-08-26
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多