PHP code example of messagemedia / webhooks-sdk

1. Go to this page and download the library: Download messagemedia/webhooks-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

messagemedia / webhooks-sdk example snippets



icAuthUserName = 'YOUR_API_KEY'; // The username to use with basic authentication
$basicAuthPassword = 'YOUR_SECRET_KEY'; // The password to use with basic authentication

$client = new MessageMediaWebhooksLib\MessageMediaWebhooksClient($basicAuthUserName, $basicAuthPassword);

$webhooks = $client->getWebhooks();

$body = new MessageMediaWebhooksLib\Models\CreateWebhookRequest();
$body->url = "http://webhook.com/asdasd";
$body->method = "POST";
$body->encoding = "JSON";
$body->headers = array("x-your-webhook-custom-header" => "custom-value");
$body->events = array("RECEIVED_SMS");
$body->template = '{"id":"$mtId","status":"$statusCode"}';

$result = $webhooks->createWebhook($body);


icAuthUserName = 'YOUR_API_KEY'; // The username to use with basic authentication
$basicAuthPassword = 'YOUR_SECRET_KEY'; // The password to use with basic authentication

$client = new MessageMediaWebhooksLib\MessageMediaWebhooksClient($basicAuthUserName, $basicAuthPassword);

$webhooks = $client->getWebhooks();

$page  =  0;
$pageSize  =  10;

$result  =  $webhooks->retrieveWebhook($page, $pageSize);
print_r($result);


icAuthUserName = 'YOUR_API_KEY'; // The username to use with basic authentication
$basicAuthPassword = 'YOUR_SECRET_KEY'; // The password to use with basic authentication

$client = new MessageMediaWebhooksLib\MessageMediaWebhooksClient($basicAuthUserName, $basicAuthPassword);

$webhooks = $client->getWebhooks();

$webhookId = "YOUR_WEBHOOK_ID";

$body = new MessageMediaWebhooksLib\Models\CreateWebhookRequest();
$body->url = "http://webhook.com/some_new_url";
$body->method = "POST";
$body->encoding = "JSON";
$body->headers = array("Account" => "teasdasdst");
$body->events = array("RECEIVED_SMS");
$body->template = '{"id":"$mtId","status":"$statusCode"}';


$result = $webhooks->updateWebhook($webhookId, $body);


icAuthUserName = 'YOUR_API_KEY'; // The username to use with basic authentication
$basicAuthPassword = 'YOUR_SECRET_KEY'; // The password to use with basic authentication

$client = new MessageMediaWebhooksLib\MessageMediaWebhooksClient($basicAuthUserName, $basicAuthPassword);

$webhooks = $client->getWebhooks();

$webhookId = "YOUR_WEBHOOK_ID";

$webhooks->deleteWebhook($webhookId);