akamomer / bulksmsiraq-sdk-v5
PHP SDK for the Bulk SMS Iraq OTP and SMS API (v5): WhatsApp, Telegram and SMS verification codes in Iraq with automatic fallback.
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Moving from
akamomer/bulksmsiraq-sdk-v5? Same code, new name: runcomposer remove akamomer/bulksmsiraq-sdk-v5 && composer require bulksmsiraq/php-sdk. The PHP namespace (BulkSMSIraq) is unchanged.
Official PHP SDK for the Bulk SMS Iraq OTP and SMS API. Send verification codes on WhatsApp, Telegram and SMS to every Iraqi network (Zain, Asiacell, Korek) with automatic fallback, verify them, and send SMS and WhatsApp templates.
- API docs: https://bulksmsiraq.com/docs/
- Get an API key (self-service, about 1 minute, free 1,670 IQD / $1 test balance): https://bulksmsiraq.com/sign-up/
- Prices (WhatsApp codes from 17 IQD / $0.01): https://bulksmsiraq.com/bulk-sms-pricing-to-iraq/
- More examples (cURL, Laravel, Node.js, Python, C#, Java, Postman): https://github.com/bulksmsiraq/api-examples
Installation
composer require bulksmsiraq/php-sdk
Requires PHP 7.4+ and Guzzle 7 (installed automatically).
Quick start
<?php require 'vendor/autoload.php'; use BulkSMSIraq\BulkSmsIraqApiClient; $client = new BulkSmsIraqApiClient(getenv('BSI_API_KEY')); // keep the key on your server $phone = '9647701234567'; // international format, no + $sender = 'YourApp'; // your Sender ID // 1) Send a code: WhatsApp first, SMS if WhatsApp can't deliver $res = $client->sendAutoOtpWithSmsFallback($phone, $sender, 'ar'); if ($res['status'] !== 'success') { exit('Error ' . $res['error']['code'] . ': ' . $res['error']['message']); } $otpId = $res['id']; // store with the user's session // 2) Verify the code the user typed (same phone number) $check = $client->verifyOtp($phone, $_POST['code'], $otpId); if ($check['status'] === 'success') { // verified } elseif ($check['error']['code'] === '1507') { // expired or locked: ask for a new code }
Methods
| Method | What it does |
|---|---|
sendAutoOtpWithSmsFallback($phone, $sender, $lang) |
We generate the code; WhatsApp, then SMS |
sendAutoOtpWithTelegramFallback($phone, $sender, $lang) |
WhatsApp, then Telegram |
sendCustomOtpWithSmsFallback($phone, $sender, $code, $lang) |
Your own numeric code; WhatsApp, then SMS |
sendCustomOtpWithTelegramFallback(...) |
Your own code; WhatsApp, then Telegram |
sendOtpWhatsAppWithoutFallback / sendOtpSmsWithoutFallback / sendOtpTelegramWithoutFallback(...) |
One channel only |
verifyOtp($phone, $code, $id) |
Check a code. Optional 5th argument true disables expiry (only if you handle it yourself) |
sendSms($phone, $sender, $text) |
SMS under your registered Sender ID, any language |
sendWhatsAppTemplate($phone, $sender, '(template)(param1)(param2)', $lang) |
Approved WhatsApp template (en/ar) |
getBalance() |
Your balance in US dollars: ['userid' => …, 'balance' => 25.43] (same API key) |
API address: https://api.bulksmsiraq.com/api/v5/ (default since v1.2.0). The previous address gateway.standingtech.com keeps working; pass it as the 2nd constructor argument if you need it.
Every method returns the decoded JSON: ['status' => 'success', ...] or ['status' => 'failed', 'error' => ['code' => '1907', 'message' => '...']]. API errors are returned, never thrown; only network failures throw GuzzleHttp\Exception\GuzzleException.
Good to know
| Topic | Details |
|---|---|
| Code expiry | WhatsApp: the message tells the user 3 minutes (verify accepts up to 30). SMS: 30 minutes. Telegram: 2 minutes. Locked after 5 wrong attempts. |
| Languages | en, ar, ku (Kurdish Sorani), fa. WhatsApp codes: English or Arabic only (Meta's limit); Kurdish and Persian text on SMS. |
| Billing | WhatsApp: you pay only for delivered messages; if it falls back to SMS you pay the SMS price only. |
| Limits | Per number: 2 codes / 30 s (1907), 10 / hour (1906), 15 / day (1905). Test numbers can be whitelisted. |
| Errors | Full list: https://bulksmsiraq.com/docs/#errors |
| Security | Never put the API key in a mobile app, browser code or a public repo. Restrict the key to your server IPs in the dashboard. |
Support
Bulk SMS Iraq (StandingTech), Four Towers, Erbil · Official Meta Tech Partner Technical support (WhatsApp): +964 750 217 1212 · Sales: +964 750 216 1212 · https://bulksmsiraq.com/contact/
License
MIT