Comprehensive reference for every method provided by the dreamsms/laravel-dreamsms package.
composer require dreamsms/laravel-dreamsms
php artisan vendor:publish --provider="DreamSms\LaravelDreamSms\DreamSmsServiceProvider" --tag=config
Add these to your .env:
DREAMSMS_BASE_URL=https://www.dreams.sa/index.php/api
DREAMSMS_USER=your_username
DREAMSMS_SECRET_KEY=your_api_secret_key
DREAMSMS_CLIENT_ID=your_oauth_client_id
DREAMSMS_CLIENT_SECRET=your_api_secret_key # as DREAMSMS_SECRET_KEY
DREAMSMS_SENDER_NAME=your_sender_name
config/dreamsms.php)return [
'base_url' => env('DREAMSMS_BASE_URL'),
'account_username' => env('DREAMSMS_USER'),
'secret_key' => env('DREAMSMS_SECRET_KEY'),
'client_id' => env('DREAMSMS_CLIENT_ID'),
'client_secret' => env('DREAMSMS_CLIENT_SECRET'),
'sender_name' => env('DREAMSMS_SENDER_NAME'),
];
Your Account Username is the username you use to log in to your Dreams account.
To obtain your client_id:
Visit the following URL:
Copy the displayed client_id.
To retrieve your client_secret:
Go to your profile page:
Copy your client_secret from the information displayed there.
To get your default Sender Name:
Navigate to:
Identify and copy the default Sender Name from your listed sender names.
Use the Facade or inject the DreamSms service.
use DreamSms; // Facade
// OR via DI
public function __construct(DreamSms\LaravelDreamSms\DreamSms $sms)
{
$this->sms = $sms;
}
Each section details endpoint, parameters, expected response, and Laravel usage.
register(array $user): arrayDescription: Register a new DreamSMS user account.
| HTTP Method | Endpoint |
|---|---|
| POST | /Register |
| Name | Type | Required | Description |
|---|---|---|---|
| user | string | yes | Desired username |
| password | string | yes | Password (min 6 chars) |
| name | string | yes | Full name |
| mobile | string | yes | Mobile number (e.g. 9665...) |
| string | yes | Valid e‑mail address |
$response = DreamSms::register([
'user' => 'newuser',
'password' => 'pass1234',
'name' => 'John Doe',
'mobile' => '966512345678',
'email' => 'john@example.com',
]);
{
"code": 999,
"message": "Success register user",
"data": { /* user details */ }
}
100: Missing parameters110: Username already used111: Mobile already used112: Email already used120: Username contains invalid characters121: Password too short (<6)122: Invalid username123: Invalid passwordgenerateToken(): arrayDescription: Obtain OAuth2 Bearer token.
| HTTP Method | Endpoint |
|---|---|
| POST | /token/generate |
| Name | Type | Required | Description |
|---|---|---|---|
| grant_type | string | yes | Must be client_credentials |
| client_id | string | yes | OAuth client ID |
| client_secret | string | yes | OAuth client secret |
$tokenData = DreamSms::generateToken();
{
"token_type": "Bearer",
"expires_in": 3600,
"access_token": "eyJ0e..."
}
401 invalid_client: Authentication failed400 unsupported_grant_type: Wrong grant typeactivate(string $user, string $code): arrayDescription: Activate a newly registered account.
| HTTP Method | Endpoint |
|---|---|
| POST | /activate |
| Name | Type | Required | Description |
|---|---|---|---|
| user | string | yes | Username |
| secret_key | string | yes | API secret key |
| code | string | yes | Activation code |
DreamSms::activate('newuser', '123456');
999: Success100: Missing parameters110: Invalid username or secret_key111: Wrong activation codecheckUser(): arrayDescription: Verify account credentials and activation status.
| HTTP Method | Endpoint |
|---|---|
| POST | /chk_user |
| Name | Type | Required | Description |
|---|---|---|---|
| user | string | yes | Username |
| secret_key | string | yes | API key |
{ "code": 999, "message": "Valid account" }
-100: Missing parameters-110: Account not exist or wrong credentials-111: Account not activated-112: Blocked accountbalance(): arrayDescription: Retrieve SMS credit balance.
| HTTP Method | Endpoint |
|---|---|
| POST | /chk_balance |
| Name | Type | Required | Description |
|---|---|---|---|
| user | string | yes | Username |
| secret_key | string | yes | API key |
{ "balance": 123.45 }
-100: Missing parameters-110: Invalid credentialsaddSender(string $sender): arrayDescription: Create a new sender name.
| HTTP Method | Endpoint |
|---|---|
| POST | /newsender |
| Name | Type | Required | Description |
|---|---|---|---|
| user | string | yes | Username |
| secret_key | string | yes | API key |
-113: Duplicate sender-114: Invalid sender name (chars or length)senderStatus(string $sender): arrayDescription: Check activation status of a sender.
| HTTP Method | Endpoint |
|---|---|
| POST | /senderstatus |
| Name | Type | Required | Description |
|---|---|---|---|
| user | string | yes | Username |
| secret_key | string | yes | API key |
Active, UnActive, RejecteduserSenders(): arrayDescription: List all senders for your account.
| HTTP Method | Endpoint |
|---|---|
| POST | /usersender |
<usersender>
<sender>
<id>52</id>
<text>MySender</text>
<status>Active</status>
<default>false</default>
<date>2025-06-01</date>
<notes>...</notes>
</sender>
</usersender>
sendSms(string $to, string $message, string $sender, array $options = []): arrayDescription: Send a single SMS, optionally with calendar reminder.
| HTTP Method | Endpoint |
|---|---|
| POST | /sendsms |
| Name | Type | Description |
|---|---|---|
| user | string | Username |
| secret_key | string | API key |
| to | string | Recipient mobile number |
| message | string | Message body |
is_calander = 1)| Name | Description |
|---|---|
| calander_date | YYYY-MM-DD |
| calander_time | HH:MM |
| reminder | Minutes before event |
| reminder_text | Reminder message |
| location_url | Google Maps URL |
DreamSms::sendSms(
'966512345678',
'Meeting at 5pm',
[
'is_calander' => 1,
'calander_date' => '2025-07-01',
'calander_time' => '17:00',
'reminder' => 30,
'reminder_text' => 'Don’t forget!',
]
);
SMS_ID:mobileNumber on success-113 insufficient balance, -119 invalid datetime, etc.)sendMulti(array $toWithMsg, string $sender): arrayDescription: Send different messages to multiple recipients in one request.
| HTTP Method | Endpoint |
|---|---|
| POST | /sendsms_multi |
| Name | Type | Description |
|---|---|---|
| user | string | Username |
| secret_key | string | API key |
| to | string | JSON: {"9665...":"Msg1","9665...":"Msg2"} |
DreamSms::sendMulti([
'966512345678' => 'Hello Alice',
'966512345679' => 'Hello Bob',
]);
Same format as single sendSms response.
Catch DreamSms\LaravelDreamSms\Exceptions\DreamSmsException to manage HTTP or API errors:
try {
DreamSms::sendSms(...);
} catch (DreamSmsException $e) {
report($e);
// handle or display $e->getMessage()
}
feature/your-featurePlease follow PSR-12 and include tests for new methods.
MIT. See LICENSE.
How can I help you explore Laravel packages today?