为什么我的 SendinBlue 网络钩子不工作?

时间:2020-12-31 19:32:58

标签: php webhooks sendinblue

我是 webhooks 的新手,但我已经成功地将它们与 Stripe 一起使用,所以在尝试将它们与 SendinBlue 一起使用时,我无法弄清楚我在这里做错了什么。

根据 SendinBlue 文档,这是响应的样子:

{
"url":"http://example.domain.com/1brxxxxxx5p1"
"id":7287
"description":"Webhook triggered on campaign openings and addition of lists"
"events":[
0:"listAdditions"
1:"opened"
]
"type":"marketing" //other option here is "transactional", which is what I'm testing for.
"createdAt":"2016-06-07T09:10:10.000Z"
"modifiedAt":"2016-06-08T11:30:00.000Z"
}

这是我的端点代码:

<?php
    require_once('../vendor/autoload.php'); 

    $config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', SB_KEY);

$apiInstance = new SendinBlue\Client\Api\WebhooksApi(
    new GuzzleHttp\Client(),
    $config
);

    $payload = @file_get_contents('php://input');
$event = null;

try {
    
    $event = $apiInstance->getWebhooks(
        $payload
    );
} 

if($event->type == 'transactional'){

$header = "";
    $body = "Result: $event ";
    $sub = "Webhook Sent";
    $pre = "";
    
    //this is a function to send an email that is working correctly when tested outside of this if statement

    send_email("test@yahoo.com", $header, $body, $sub, $pre);


}


http_response_code(200);

?>

有人可以向我解释我做错了什么吗?

0 个答案:

没有答案