-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-xml-webhook.php
38 lines (32 loc) · 1.1 KB
/
create-xml-webhook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once('vendor/autoload.php');
require_once('config.php');
$basicAuthUserName = API_KEY; // The username to use with basic authentication
$basicAuthPassword = API_SECRET; // The password to use with basic authentication
$client = new MessageMediaWebhooksLib\MessageMediaWebhooksClient($basicAuthUserName, $basicAuthPassword);
$webhooks = $client->getWebhooks();
$body = new MessageMediaWebhooksLib\Models\CreateWebhookRequest();
$body->url = NGROK_URL . '/webhooks-demo/index.php';
$body->method = "POST";
$body->encoding = "XML";
$body->headers = array("X-Custom-Header" => "Hello world!");
$body->events = array("RECEIVED_SMS");
$body->template = '<message>
<content>
<original>$mtContent</original>
<reply>$moContent</reply>
</content>
<addresses>
<recipient>$destinationAddress</recipient>
<sender>$sourceAddress</sender>
</addresses>
<serviceType>$type</serviceType>
<messageId>$mtId</messageId>
<replyId>$moId</replyId>
</message>';
try {
$result = $webhooks->createWebhook($body);
} catch (Exception $e) {
var_dump($e);
}
var_dump($result);