1. Go to this page and download the library: Download devriyad/giosms 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/ */
devriyad / giosms example snippets
use GioSMS\Facades\GioSMS;
GioSMS::send([
'to' => '8801712345678',
'message' => 'Hello from GioSMS!',
]);
ioSMS\GioSMS;
$sms = new GioSMS([
'token' => 'your-api-token-here',
'sender_id' => 'MyBrand', // optional default sender ID
'timeout' => 30, // optional, seconds (default: 30)
// 'ssl_verify' => false, // uncomment for local dev without SSL
]);
// Send an SMS
$result = $sms->send([
'to' => '8801712345678',
'message' => 'Hello from GioSMS!',
]);
print_r($result);
// Get report for a specific batch
$result = GioSMS::batch([
'batch_id' => 'batch_m1abc_7kR4xWz9pQ2n',
]);
echo $result['data']['status']; // "completed" or "processing"
echo $result['data']['total_sent']; // 4900
echo $result['data']['total_failed']; // 88
// If still processing, live_stats will be present:
// $result['data']['live_stats']['delivered']
// $result['data']['live_stats']['pending']
// List all active (in-progress) batches
$result = GioSMS::activeBatches();
echo $result['data']['count']; // number of active batches
// Get batch history (most recent first)
$result = GioSMS::batchHistory(); // default: 20 records
$result = GioSMS::batchHistory(['limit' => 50]); // up to 100
use GioSMS\Facades\GioSMS;
use GioSMS\Exceptions\AuthenticationException;
use GioSMS\Exceptions\InsufficientBalanceException;
use GioSMS\Exceptions\ValidationException;
use GioSMS\Exceptions\RateLimitException;
use GioSMS\Exceptions\GioSMSException;
try {
$result = GioSMS::send([
'to' => '8801712345678',
'message' => 'Hello!',
]);
} catch (AuthenticationException $e) {
// 401 — Your API token is invalid or missing
// Fix: Check GIOSMS_TOKEN in your .env
} catch (InsufficientBalanceException $e) {
// 402 — Not enough balance to send this message
// Fix: Top up your GioSMS account
} catch (ValidationException $e) {
// 400/422 — Invalid request parameters
// Fix: Check
use GioSMS\GioSMS;
use Illuminate\Http\Request;
class OrderController extends Controller
{
public function store(Request $request, GioSMS $sms): JsonResponse
{
$order = Order::create($request->validated());
$sms->send([
'to' => $order->phone,
'message' => "Order #{$order->id} confirmed! Total: ৳{$order->total}",
]);
return response()->json($order, 201);
}
}
use GioSMS\GioSMS;
class SendOrderConfirmation implements ShouldQueue
{
public function __construct(
private Order $order,
) {}
public function handle(GioSMS $sms): void
{
$sms->send([
'to' => $this->order->phone,
'message' => "Order #{$this->order->id} has been shipped!",
'type' => 'transactional',
]);
}
}