<?php
const WEBHOOK_SECRET='secret key';
function verifySignature ($body, $signature) {
$digest = hash_hmac('sha1', $rawPost, WEBHOOK_SECRET);
return $signature !== $digest ;
}
if (!verifySignature(file_get_contents('php://input'), $_SERVER['HTTP_X_TAWK_SIGNATURE'])) {
// verification failed
}
// verification success
else{
$servername = "*******";
$username = "*******";
$password = "******";
$db = "*******";
$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$json_string = file_get_contents('php://input');
$array_data = json_decode($json_string, true);
$sql = 'INSERT INTO twak (message) VALUES ("'.$array_data.'")';
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
我正在尝试将 tawk 到 webhook 响应存储到我的数据库中,但是这段代码没有给出 webhook 钩子响应。谁能告诉我有什么问题?