Я использовал это: https://developers. Hubspot.com/docs/api/webhooks/validating-requests.
Но $_SERVER['HTTP_X_HUBSPOT_SIGNATURE_V3'] не соответствует моей хешированной строке.
Вот код:
Код: Выделить всё
$request_method = $_SERVER['REQUEST_METHOD']; //returns: POST
$request_uri = $_SERVER['REQUEST_URI']; // returns: /hubspot/webhook.php
$request_body = file_get_contents('php://input');
//returns: {"email":"test@gmail.com","field1":null,"field2":null,"field3":null,"field4":null}
$request_timestamp = $_SERVER['HTTP_X_HUBSPOT_REQUEST_TIMESTAMP'];// returns: 1679654017505
$string = utf8_encode("{$request_method}{$request_uri}{$request_body}{$request_timestamp}"); //POST/hubspot/webhook.php{"email":"test@gmail.com","field1":null,"field2":null,"field3":null,"field4":null}1679654017505
$HUBSPOT_APP_SECRET = '...';
$hash = hash_hmac('sha256', $string, $HUBSPOT_APP_SECRET, true); //returns odd characters: ���_*�...
$encoded = base64_encode($hash);
$valid = hash_equals($_SERVER['HTTP_X_HUBSPOT_SIGNATURE_V3'], $encoded);
if($valid == 1) {
echo 'yes';
}else {
echo 'no';
}
Пожалуйста, помогите!
Подробнее здесь: https://stackoverflow.com/questions/758 ... re-hubspot
Мобильная версия