PHP code example of farazsms / php
1. Go to this page and download the library: Download farazsms/php 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/ */
farazsms / php example snippets
FarazSMS\FarazSMS;
use FarazSMS\FarazException;
$sms = new FarazSMS("YOUR_API_KEY"); // key from the panel → Web Service / API Key
print_r($sms->balance()); // verify the key — free
$sms->sendPattern("SJ3FgPrE0C", "09120000000", ["code" => "1234"]); // OTP (instant)
$sms->sendSimple("Hello!", ["09120000000", "09130000000"]); // bulk
print_r($sms->inbox(1, 20)); // inbound replies
try {
$sms->sendPattern("BAD", "09120000000", ["code" => "1"]);
} catch (FarazException $e) {
echo $e->statusCode . " " . $e->getMessage();
}
bash
composer