Quickstart
This example sends a simulated message. It exercises request validation and the API integration without consuming credits or delivering a message to the handset.
-
Install the SDK:
Terminal window composer require rayo-sms/rayo-sms-php-sdk -
Set your API key in the environment:
Terminal window export SMS_API_KEY='replace-with-your-private-api-key' -
Save and run the following script:
<?php require_once 'vendor/autoload.php'; use Rayo\SmsSdk\Client; use Rayo\SmsSdk\Exceptions\RayoException; $client = new Client( getenv('SMS_API_KEY'), 'https://sms-api.rayo.gr/v1' ); try { $response = $client->sendSms([ 'fromLabel' => 'MYBRAND', 'toMobileNumber' => '306912345678', 'smsBody' => 'Hello from the PHP SDK!', 'simulateSendFlag' => true, ]); echo $response->getSmsServerRequestId() . PHP_EOL; } catch (RayoException $exception) { echo $exception->getMessage() . PHP_EOL; }
On success, sendSms() returns an SmsResponse. Use isSuccess(), getSmsServerRequestId(), and getClientRequestId() to connect the response to your application records.
Continue to Sending SMS for recipients, groups, callbacks, concatenation, and the SmsRequest value object.
