1. Go to this page and download the library: Download nextsms/php-client 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/ */
nextsms / php-client example snippets
use Nextsms\Nextsms;
$client = Nextsms::create(
username: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD',
from: 'NEXTSMS'
);
$helloMessage = $client->messages()->send([
"to": '2557123456789',
"text": 'Hello World',
// from is optional if you have set it in the constructor
]);
// Or
$message = Message::create(text: 'Hello World',to: '2557123456789');
$helloMessage = $client->messages()->send($message);
// Send Later
$messageScheduled = $client->messages()->sendLater(
new Message(to: '2557123456789', text: 'Hello World'),
\DateTime::createFromFormat('Y-m-d', '2020-12-31')
);
// Send to many
$manyMessages = $client->messages()->sendMany(
MessageCollection::create([
Message::text(to: '2557123456789', text: 'Hello World'),
Message::text(to: '2557123456789', text: 'Hello World'),
])
);
// Or
$manyMessages = $client->messages()->sendMany(
MessageCollection::create([
Message::text(to: '2557123456789', text: 'Hello World'),
Message::text(to: [ '2557123456789', '2557123456789' ], text: 'Hello World'),
]);
);
// Delivery reports
$allReports = $client->reports()->all();
// Query
$reports = $client->reports()
->query()
// Using date string
->sentFrom(date: '01-01-2022')
// Or using date object
->sentUntil(date: \DateTime::create('now'))
->get();
$report = $client->reports()->get($messageId);
//
// Customer
$customer = Customer::create([
"first_name" => "Api",
"last_name" => "Customer",
"username" => "api_customer",
"email" => "[email protected]",
"phone_number" => "0738234339",
"account_type" => "Sub Customer (Reseller)",
"sms_price" => 200
]);
// Create
$customer = $client->customers()->create($customer);
// Recharge
$recharge = $client->customers()->recharge($customer, 1000);
// Deduct
$deduct = $client->customers()->deduct($customer, 1100);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.