Inspired by the official package. The official package just working in laravel! This package working in every PHP project
PHP Versions Supported: 7.3, 7.4, 8.0, 8.1
Laravel Versions Supported: 8, 9, 10
composer require amirbagh75/smsir-php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Amirbagh75\SMSIR\SmsIRClient;
$apiKey = getenv('API_KEY');
$secretKey = getenv('SECRET_KEY');
$lineNumber = getenv('LINE_NUMBER');
$timeOut = 3;
$smsir = new SmsIRClient($apiKey, $secretKey, $lineNumber, $timeOut);
try {
$res = $smsir->getSentMessages(1, 250);
print_r($res->messages);
print_r($res->countOfAll);
} catch (Throwable $e) {
error_log($e->getMessage(), 0);
}
First add these environment variables in your .env file:
SMSIR_API_KEY="xxxx"
SMSIR_SECRET_KEY="xxxx"
SMSIR_LINE_NUMBER="xxxx"
SMSIR_HTTP_TIMEOUT="10"
Then use it like the following example:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Example extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
// do something ...
try {
$res = SMSIR::getSentMessages('1399/06/01', '1399/10/01', 1, 250);
dd($res);
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
Log::error($e->getMessage());
}
// do something ...
}
}
Response models structures are in the src/Responses
directory
smsCredit(): CreditResponse
getSMSLines(): SMSLinesResponse
send(array $messages, array $mobileNumbers, $sendDateTime = null): SendResponse
sendVerificationCode(string $code, string $mobileNumber): VerificationCodeResponse
ultraFastSend(array $parameters, string $templateId, string $mobileNumber): VerificationCodeResponse
getSentMessages($fromDate, $toDate, $pageNumber = 1, $perPage = 100): SentMessagesResponse
getReceivedMessages($fromDate, $toDate, $pageNumber = 1, $perPage = 100): ReceivedMessagesResponse
We use Semantic Versioning. See the available versions.
- Amirhossein Baghaie - Maintainer
- Ariaieboy - Collaborator