1. Go to this page and download the library: Download messagemedia/messages-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 / messages-sdk example snippets
MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$messagesController = $client->getMessages();
$body = new Models\SendMessagesRequest;
$body->messages = array();
$body->messages[0] = new Models\Message;
$body->messages[0]->content = 'My first message';
$body->messages[0]->destinationNumber = '+61491570156';
try {
$result = $messagesController->sendMessages($body);
print_r($result);
} catch (Exceptions\SendMessages400Response $e) {
echo 'Caught SendMessages400Response: ', $e->getMessage(), "\n";
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$messagesController = $client->getMessages();
$body = new Models\SendMessagesRequest;
$body->messages = array();
$body->messages[0] = new Models\Message;
$body->messages[0]->content = 'My second message';
$body->messages[0]->destinationNumber = '+61491570156';
$body->messages[0]->format = Models\FormatEnum::MMS;
$body->messages[0]->media = array('https://images.pexels.com/photos/1018350/pexels-photo-1018350.jpeg?cs=srgb&dl=architecture-buildings-city-1018350.jpg');
$body->messages[0]->subject = 'This is an MMS message';
try {
$result = $messagesController->sendMessages($body);
print_r($result);
} catch (Exceptions\SendMessages400Response $e) {
echo 'Caught SendMessages400Response: ', $e->getMessage(), "\n";
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$messagesController = $client->getMessages();
$messageId = '877c19ef-fa2e-4cec-827a-e1df9b5509f7';
try {
$result = $messagesController->getMessageStatus($messageId);
print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$repliesController = $client->getReplies();
try {
$result = $repliesController->checkReplies();
print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$deliveryReportsController = $client->getDeliveryReports();
try {
$result = $deliveryReportsController->checkDeliveryReports();
print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
MessageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$deliveryReportsController = $client->getDeliveryReports();
$body = new Models\ConfirmDeliveryReportsAsReceivedRequest;
$body->deliveryReportIds = array('011dcead-6988-4ad6-a1c7-6b6c68ea628d', '3487b3fa-6586-4979-a233-2d1b095c7718', 'ba28e94b-c83d-4759-98e7-ff9c7edb87a1');
try {
$result = $deliveryReportsController->confirmDeliveryReportsAsReceived($body);
print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
essageMediaMessagesLib\Models;
use MessageMediaMessagesLib\Exceptions;
$authUserName = 'API_KEY';
$authPassword = 'API_SECRET';
/* You can change this to true when the above keys are HMAC */
$useHmacAuthentication = false;
$client = new MessageMediaMessagesLib\MessageMediaMessagesClient($authUserName, $authPassword, $useHmacAuthentication);
$messagesController = $client->getMessages();
try {
$result = $messagesController->checkCreditsRemaining();
print_r($result);
} catch (MessageMediaMessagesLib\APIException $e) {
echo 'Caught APIException: ', $e->getMessage(), "\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.