0

I can able to subscribe webhook using exact online API,i am not able to get response to CallbackURL from webhook notification.

I subscribed using below request:

$subscription = new \Picqer\Financials\Exact\WebhookSubscription($connection);
$subscription->deleteSubscriptions();
$subscription->CallbackURL = $callback;
$subscription->Topic = $topic;
$subscription->save(); 

Please give me suggestion to get webhook notification through exact online php API.

4

1 回答 1

0

成功注册 webhook 后。

我找到了如何在 CallbackURL 中处理请求的解决方案。

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

你会得到 json 响应。

按照下面的示例,您可以验证您的 webhook 响应。

$requestContent= file_get_contents('php://input');  // (this is json response)
$webhookSecret='XXXXXXXXXXXXXXXX'; //your webhook Secret key

$returnvalue=authenticate($requestContent,$webhookSecret); // this will get either true/false
function authenticate($requestContent, $webhookSecret)
    {
        $matches = [];
        $matched = preg_match('/^{"Content":(.*),"HashCode":"(.*)"}$/', $requestContent, $matches);

        if ($matched === 1 && isset($matches[1]) && isset($matches[2])) {
            return $matches[2] === strtoupper(hash_hmac('sha256', $matches[1], $webhookSecret));
        }
        return false;
    }

在此处输入图像描述

于 2018-07-13T13:13:07.210 回答