laravel maintained by ghasedak
Table of Contents
Install
The easiest way to install is by using Composer:
composer require ghasedak/laravel
Composer is a dependency manager for PHP which allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. If you are not familiar with Composer, you can read its documentations and download it via getcomposer.org.
Update
Set this line to Composer.json file in your project:
"ghasedak/laravel": "*"
Then run following command to update using composer
composer update
Composer update the required packages on your local machine.
usage
To use the package, you need an API key. To get that you should have a Ghasedak account. Register and get your API key.
Copy the following variable into your project's .env file and change your_api_key to the key you have got from your Ghasedak account.
GHASEDAKAPI_KEY=your_api_key
Use GhasedakFacade on top of your controller or wherever you want:
use Ghasedak\Laravel\GhasedakFacade;
then you can use GhasedakApi methods statically, to use SendSimple
$response = GhasedakFacade::SendSimple($receptor, $message, $lineNumber = null, $sendDate = null, $checkId = null);
####OR
$response = Ghasedak\Laravel\GhasedakFacade::SendSimple($receptor, $message, $lineNumber = null, $sendDate = null, $checkId = null);
Parameters
| Parameter | Required | Description | Type | Example |
|---|---|---|---|---|
| message | Yes | Text to be sent | string | Hello, World! |
| receptor | Yes | The number of the recipient(s) of the message (seperated by comma ,). |
string | 09111111111 |
| linenumber | No | The number of the sender of the message, which, if not specified, will be selected from your dedicated lines with a higher priority.(If you do not have a dedicated line, you must specify the linenumber) |
string | 5000222 |
| senddate | No | The exact date and time of sending the message based on Unix time, if not specified, the message will be sent instantly. | string | 1508144471 |
Example
Here is a sample code for sending SMS. Please note that you must specify line number if you don't have a dedicated line.
$receptor = '09xxxxxxxxx';
$message = 'Hello, World!';
$lineNumber = '3000xxxxx';
$response = Ghasedak\Laravel\GhasedakFacade::SendSimple($receptor, $message, $lineNumber);
One-Time Passwords (OTP)
The One-Time-Password (OTP) Interface is used to perform a mobile authentication or to implement Two-Factor-Authentication (2FA).
You can pass up to 10 param to Verify method:
$response = Ghasedak\Laravel\GhasedakFacade::setVerifyType(Ghasedak\Laravel\GhasedakFacade::VERIFY_MESSAGE_TEXT)
->Verify(
"09xxxxxxxxx", // receptor
"my-template", // name of the template which you've created in you account
"param1", // parameters (supporting up to 10 parameters)
"param2",
"param3"
);
Parameters
| Parameter | Required | Description | Type | Example |
|---|---|---|---|---|
| receptor | Yes | The number of the recipient of the message. | string | 09111111111 |
| type | Yes | Set 1 to send text message and 2 to send voice message. |
int | Hello, World! |
| template | Yes | The title of the template you created in your panel. | string | my-template |
| checkid | No | It is used to set a unique number for each SMS, and after sending the SMS, all the information of the sent message can be received with the status method. |
string | 2071 |
| param1 | Yes | The values you enter (You must enter at least one parameter). | string | abcdef |
| param2 | No | The values you enter. | string | abcdef |
| param3 | No | The values you enter. | string | abcdef |
| param4 | No | The values you enter. | string | abcdef |
| param5 | No | The values you enter. | string | abcdef |
| param6 | No | The values you enter. | string | abcdef |
| param7 | No | The values you enter. | string | abcdef |
| param8 | No | The values you enter. | string | abcdef |
| param9 | No | The values you enter. | string | abcdef |
| param10 | No | The values you enter. | string | abcdef |
Example
$receptor = "09xxxxxxxxx";
$type = Ghasedak\Laravel\GhasedakFacade::VERIFY_MESSAGE_TEXT;
$template = "my-template";
$param1 = '123456';
$response = Ghasedak\Laravel\GhasedakFacade::setVerifyType($type)->Verify($receptor, $template, $param1);
:)
License
Freely distributable under the terms of the MIT license.
composer require ghasedak/laravel
"ghasedak/laravel": "*"
composer update
GHASEDAKAPI_KEY=your_api_key
use Ghasedak\Laravel\GhasedakFacade;
$response = GhasedakFacade::SendSimple($receptor, $message, $lineNumber = null, $sendDate = null, $checkId = null);
####یا
$response = Ghasedak\Laravel\GhasedakFacade::SendSimple($receptor, $message, $lineNumber = null, $sendDate = null, $checkId = null);
:))
$receptor = '09xxxxxxxxx';
$message = 'Hello, World!';
$lineNumber = '3000xxxxx';
$response = Ghasedak\Laravel\GhasedakFacade::SendSimple($receptor, $message, $lineNumber);
$response = Ghasedak\Laravel\GhasedakFacade::setVerifyType(Ghasedak\Laravel\GhasedakFacade::VERIFY_MESSAGE_TEXT)
->Verify(
"09xxxxxxxxx", // receptor
"my-template", // name of the template which you've created in you account
"param1", // parameters (supporting up to 10 parameters)
"param2",
"param3"
);
$receptor = "09xxxxxxxxx";
$type = Ghasedak\Laravel\GhasedakFacade::VERIFY_MESSAGE_TEXT;
$template = "my-template";
$param1 = '123456';
$response = Ghasedak\Laravel\GhasedakFacade::setVerifyType($type)->Verify($receptor, $template, $param1);