# ABM SMS Gateway - PHP SDK

SPEC.md §10. A single dependency-free, PHP 7.2+ compatible file - drop `AbmSms.php` into any PHP codebase (no Composer, no autoloading, cURL only) and call it directly.

## Install

Copy `AbmSms.php` into your project (e.g. a legacy CI3 app's `application/third_party/`) and `require` it.

```php
require 'AbmSms.php';

$sms = new AbmSms('abmsms_live_xxxxxxxx', 'YOUR_SECRET');

$sms->send('01712345678', 'আপনার বাইক সার্ভিস রেডি।', ['client_reference' => 'SVC-4471']);
$sms->sendBulk($recipientsArray, ['name' => 'Eid Offer']);
$sms->estimate($to, $message);
$sms->status($messageUuid);
$sms->bulkStatus($messageUuids); // what a cron job should poll (SPEC §5.4)
$sms->balance();
AbmSms::verifyWebhook($rawBody, $signatureHeader, $secret);
```

Every call returns a plain associative array (the response envelope's `data` object) or throws a single `AbmSmsException` - `getErrorCode()`, `getHttpStatus()`, `getDetails()`. Never retries a 4xx; only a genuine connection failure (DNS/timeout/refused) gets retried, up to 3 attempts total.

Full reference: [docs/api.md](../docs/api.md) ([Bangla quick-start](../docs/api.bn.md)). Postman collection: [docs/postman/abmsms.postman_collection.json](../docs/postman/abmsms.postman_collection.json).

## CI3 integration example

`examples/ci3/application/` shows the three pieces SPEC §10 asks for, wired together:

- `config/abmsms.php` - credentials + base URL, kept out of version control in a real app.
- `third_party/abmsms/AbmSms.php` - a copy of the SDK file itself (CI3 convention: third-party code lives under `third_party/`, not `libraries/`). **Keep this in sync with the canonical `sdk/AbmSms.php` above if you edit either one.**
- `libraries/Abmsms_lib.php` - a thin CI3-idiomatic (snake_case) wrapper around the SDK, loaded via `$this->load->library('abmsms_lib')`.
- `controllers/Sms_example.php` - a normal send, an inbound webhook receiver (signature-verified), and the `POST /sms/status` cron-poll pattern SPEC §5.4 calls out by name for apps that can't receive webhooks at all.

Copy the four files into the matching paths under your own `application/`, fill in real credentials in `config/abmsms.php`, and you're integrated - that's the whole SPEC §10 DoD ("a CI3 app integrates in under 15 minutes using only the docs").
