如何订阅确切的在线Webhooks

时间:2018-07-06 15:17:19

标签: php exact-online picqer-exact-php-client

我可以使用确切的在线API订阅Webhook,但无法从Webhook通知获得对CallbackURL的响应。

我使用以下请求进行了订阅:

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

请给我建议,以通过确切的在线php API获取Webhook通知。

1 个答案:

答案 0 :(得分:0)

成功注册Webhook之后。

我找到了解决方法,该方法如何处理CallbackURL中的请求。

    SOAPBindingMessageContext soapbindingmessagecontext = (SOAPBindingMessageContext) iContext;
    javax.xml.soap.SOAPMessage soapMessage = soapbindingmessagecontext.getRequestMessage();
    Iterator iterator = soapMessage.getMimeHeaders().getAllHeaders();
    while (iterator.hasNext()) { 
        MimeHeader header = (MimeHeader) iterator.next();
        System.out.println(header.getName());
        System.out.println(header.getValue().toString());
        if (header.getName().equalsIgnoreCase("SOAPAction")) {
            System.out.println("The soapAction is  : " + header.toString());
            operationName = header.getValue().replaceAll("\"", "");
        }
    }
    if (debug) {
        System.out.println(operationName);
    }

您将收到json响应。

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

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

enter image description here