bahmanshams / smsir-php

📩 Unofficial sms.ir PHP/Laravel Package.

Home Page:https://sms.ir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StyleCI Latest Stable Version Total Downloads License

Unofficial PHP Package for sms.ir

Inspired by the official package. The official package just working in laravel! This package working in every PHP project (PHP ^7.3).

How to install:

composer require amirbagh75/smsir-php

Example

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Amirbagh75\SMSIR\SmsIRClient;

$apiKey = getenv('API_KEY');
$secretKey = getenv('SECRET_KEY');
$lineNumber = getenv('LINE_NUMBER');

$smsir = new SmsIRClient($apiKey, $secretKey, $lineNumber);
try {
    $res = $smsir->getSentMessages('1399/06/01', '1399/10/01', 1, 250);
    print_r($res);
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
    error_log($e->getMessage(), 0);
}

Example in laravel (use Facades)

First add these environment variables in your .env file:

SMSIR_API_KEY="xxxx"
SMSIR_SECRET_KEY="xxxx"
SMSIR_LINE_NUMBER="xxxx"

Then use it like the following example:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use SMSIR;
use Log;

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 ...
    }
}

Current methods:

All returned models 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

Versioning

We use Semantic Versioning. See the available versions.

Authors

About

📩 Unofficial sms.ir PHP/Laravel Package.

https://sms.ir

License:MIT License


Languages

Language:PHP 100.0%