2015-06-11 133 views
1

我試圖從hipmob(即時聊天應用程序)接收一個應該在聊天事件中觸發的webhook。php - 從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); 
?> 

,但沒有成功

回答

0

我能夠與解決方案吧:

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