1. Go to this page and download the library: Download emanate/beem 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/ */
use Emanate\BeemSms\Facades\BeemSms;
BeemSms::content('Your message here')->loadRecipients(User::all())->send();
beem()->content('Your message here')->loadRecipients(User::all())->send();
// A collection of models. The phone column defaults to 'phone_number'.
BeemSms::content('Hello')->loadRecipients(User::all(), 'mobile')->send();
// An array
BeemSms::content('Hello')->getRecipients(['255700000000', '255711111111'])->send();
// Variadic arguments
BeemSms::content('Hello')->unpackRecipients('255700000000', '255711111111')->send();
BeemSms::content('Ujumbe wako hapa 😀')
->getRecipients(['255700000000'])
->senderName('SHOP') // registered, active sender ID, max 11 characters
->unicode() // for characters outside the GSM alphabet
->scheduleTime(now()->addHours(2)) // or a 'Y-m-d H:i' string in GMT+0
->jobName('welcome-sms') // dashboard tracking
->campaignTitle('January onboarding') // dashboard tracking
->send();
use Emanate\BeemSms\Exceptions\BeemApiException;
try {
$response = BeemSms::content('Hello')->getRecipients(['255700000000'])->sendAndParse();
// $response['request_id'], $response['valid'], $response['invalid'], $response['duplicates'], ...
} catch (BeemApiException $e) {
// $e->getCode() is Beem's response code, for example 102 for insufficient balance
report($e->description());
}
use Emanate\BeemSms\Events\InboundSmsReceived;
class HandleInboundSms
{
public function handle(InboundSmsReceived $event): void
{
$message = $event->message;
$message->from(); // '255701000000'
$message->to(); // your short code or long number
$message->text(); // 'STOP please'
$message->keyword(); // 'STOP'
$message->transactionId(); // use this to stay idempotent
$message->timeUtc();
$message->channel(); // 'sms'
$message->custom(); // []
$message->currency(); // 'TZS'
$message->subscriberPrice(); // '100.00'
$message->billingPrice(); // '100.00'
$message->toArray(); // the raw payload
}
}
use Emanate\BeemSms\Events\MulticountryInboundSmsReceived;
public function handle(MulticountryInboundSmsReceived $event): void
{
$event->message->from(); // SOURCEADDR
$event->message->to(); // DESTADDR, your short code or long number
$event->message->text(); // MESSAGE
$event->message->keyword(); // KEYWORD, or the first word of the message
$event->message->id(); // ID of the message being replied to, if any
}
use Emanate\BeemSms\Events\MulticountryDeliveryReportReceived;
public function handle(MulticountryDeliveryReportReceived $event): void
{
$report = $event->report;
$report->messageId(); // the msgid returned when you sent the message
$report->to(); // DESTADDR
$report->status(); // 1–11, see MulticountryDeliveryReport::STATUS_*
$report->statusText(); // 'Delivered', 'Failed', 'Expired', ...
$report->isDelivered();
$report->isUndeliverable(); // failed, deleted, expired, rejected or canceled
$report->isFinal();
}