1. Go to this page and download the library: Download messageowl/msgowl-php 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/ */
messageowl / msgowl-php example snippets
use MessageOwl\MessageOwl;
$client = new MessageOwl('your-api-key');
$client = new MessageOwl('your-api-key', useQueryAuth: true);
// Single recipient
$response = $client->message()
->to('9609848571')
->from('MyApp')
->body('Hello from MessageOwl!')
->send();
echo $response->id; // int
echo $response->message; // "Message has been sent successfully."
// Multiple recipients
$client->message()
->to(['9609848571', '9609876543'])
->from('MyApp')
->body('Hello!')
->send();
// Latest 100 messages
$messages = $client->messages()->all();
foreach ($messages as $message) {
echo $message->id;
echo $message->smsHeader;
echo $message->status;
echo $message->createdAt;
echo $message->body; // null if message.body.read scope is absent
}
use MessageOwl\Exceptions\AuthenticationException;
use MessageOwl\Exceptions\MethodNotAllowedException;
use MessageOwl\Exceptions\MessageOwlException;
use MessageOwl\Exceptions\NotFoundException;
use MessageOwl\Exceptions\RateLimitException;
use MessageOwl\Exceptions\RequestTimeoutException;
use MessageOwl\Exceptions\ServerException;
use MessageOwl\Exceptions\ValidationException;
try {
$client->message()->to('9609848571')->from('App')->body('Hi')->send();
} catch (AuthenticationException $e) {
// 401 — invalid API key
} catch (NotFoundException $e) {
// 404 — resource not found
} catch (MethodNotAllowedException $e) {
// 405
} catch (RequestTimeoutException $e) {
// 408 or connection timeout
} catch (ValidationException $e) {
// 422 — check $e->bulkLimit for bulk limit violations
if ($e->bulkLimit !== null) {
echo "Bulk limit: {$e->bulkLimit}";
}
} catch (RateLimitException $e) {
// 429 — retry after $e->retryAfter seconds
echo "Retry after: {$e->retryAfter}s";
echo "Limit: {$e->rateLimitLimit}";
echo "Remaining: {$e->rateLimitRemaining}";
echo "Reset at: {$e->rateLimitReset}";
} catch (ServerException $e) {
// 5xx
} catch (MessageOwlException $e) {
// catch-all for any other SDK error
}
use MessageOwl\Laravel\Facades\MessageOwl;
MessageOwl::message()->to('9609848571')->from('MyApp')->body('Hello!')->send();
MessageOwl::balance();
MessageOwl::senderIds();