Sending SMS
Client::sendSms() accepts either an associative array or an SmsRequest instance. At least one mobile number or contact group is required.
$response = $client->sendSms([ 'fromLabel' => 'MYBRAND', 'toMobileNumber' => ['306912345678', '306987654321'], 'toGroup' => ['Customers', 'Promotions'], 'smsBody' => 'Your order has been dispatched.', 'clientRequestId' => 'order-9543212', 'callbackWhenProcessedFlag' => true, 'simulateSendFlag' => false, 'concatFlag' => true,]);use Rayo\SmsSdk\Models\SmsRequest;
$request = new SmsRequest( 'MYBRAND', 'Your verification code is 123456.', ['306912345678', '306987654321'], null, 'verify-9543212', true, false, true);
$response = $client->sendSms($request);Arrays of phone numbers or group names are normalized into semicolon-separated strings. String values may already use semicolons or commas as supported by the API.
Request fields
Section titled “Request fields”| Field | Type | Required | Description |
|---|---|---|---|
fromLabel |
string |
Yes | Registered sender label |
smsBody |
string |
Yes | Message body, up to 1,000 characters |
toMobileNumber |
string|string[]|null |
One destination required | One or more international-format mobile numbers |
toGroup |
string|string[]|null |
One destination required | One or more account contact-group names |
clientRequestId |
string|null |
No | Your own correlation identifier |
callbackWhenProcessedFlag |
bool|null |
No | Request delivery callbacks |
simulateSendFlag |
bool|null |
No | Validate and simulate without sending |
concatFlag |
bool|null |
No | Allow concatenated SMS parts |
scheduledAt |
DateTimeInterface|string|null |
No | Future ISO-8601 delivery time |
Inspect the response
Section titled “Inspect the response”if ($response->isSuccess()) { echo $response->getUsername(); echo $response->getSmsServerRequestId(); echo $response->getClientRequestId();}The response object is immutable and also implements ArrayAccess and JsonSerializable for read-only access to the raw API response.
