First of all you will ned an API Key . You can get one Here.
| Laravel Version | Support |
|---|---|
| 3.0 | :broken_heart: |
| 4.0 | :white_check_mark: |
| 5.0 | :white_check_mark: |
| 6.0 | :white_check_mark: |
| 7.0 | :white_check_mark: |
| 8.0 | :white_check_mark: |
| 9.0 | :white_check_mark: |
We highly recomment you to always use the latest version of laravel
composer require signalads-co/laravel
"signalads/laravel": "*"
Then run following command to download extension using composer
$ composer update
Run this command in your project dirctory:
php artisan vendor:publish --tag=signalads-laravel
Now you must define your API Key and Your Line to project. for this head to config/signalads.php then put your API KEY in the code:
<?php
return [
'apikey' => '',
'sender' => '',
];
You can use the package where ever you want.
use Signalads\Laravel\Facade\Signalads;
try {
// call SignalAdsApi function
}
catch(\SignalAds\Exceptions\ApiException $e){
// در صورتی که خروجی وب سرویس 200 نباشد این خطا رخ می دهد
echo $e->errorMessage();
}
catch(\SignalAds\Exceptions\HttpException $e){
// در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد
echo $e->errorMessage();
}
$sender = "10004346"; //This is the Sender number if not set load from config
$message = "خدمات پیام کوتاه سیگنال"; //The body of SMS
$receptor = "09191234567"; //Receptors numbers
$result = Signalads::send($receptor, $message, $sender);
Sample Output
{
"data": {
"message_id": "28561b88-8403-45b8-a114-508abdb9c436",
"price": 120
},
"message": "پیام شما با موفقیت در صف ارسال قرار گرفت",
"error": {
"message": null,
"errors": null
}
}
$sender = "10004346"; //This is the Sender number if not set load from config
$message = "خدمات پیام کوتاه سیگنال"; //The body of SMS
$receptors = array("09361234567","09191234567"); //Receptors numbers
$result = Signalads::sendGroup($receptors, $message, $sender);
Sample Output
{
"data": {
"message_id": "55800454-fe52-44b3-9c44-43c87d6f29b2",
"price": 240
},
"message": "پیام شما با موفقیت در صف ارسال قرار گرفت",
"error": {
"message": null,
"errors": null
}
}
$sender = "10004346"; //This is the Sender number if not set load from config
$patternId = 123;
$patternParams = ["param 1", "param 2"];
$receptors = array("09361234567","09191234567"); //Receptors numbers
$result = Signalads::sendPattern($patternId, $patternParams, $receptors, $sender);
Sample Output
{
"data": {
"message_id": "28561b88-8403-45b8-a114-508abdb9c436"
},
"message": "پیام شما با موفقیت در صف ارسال قرار گرفت",
"error": {
"message": null,
"errors": null
}
}
StatusesPENDING = 1
SENDING = 2
BLACKLIST = 3
DELIVERED = 4
NOT_DELIVERED = 5
NOT_SENDING = 6
ERROR = 7
$messageId = 123;
$limit = 10; //optional
$offset = 0; //optional
$receptor = "09191234567"; //optional
$result = Signalads::status($messageId, $limit, $offset, $status, $receptor);
Sample Output
{
"data": {
"items": [
{
"number": "09xxxxxxxxx",
"status": 1
},
{
"number": "09xxxxxxxxx",
"status": 2
},
{
"number": "09xxxxxxxxx",
"status": 3
},
{
"number": "09xxxxxxxxx",
"status": 4
},
{
"number": "09xxxxxxxxx",
"status": 5
},
{
"number": "09xxxxxxxxx",
"status": 6
},
{
"number": "09xxxxxxxxx",
"status": 7
}
],
"count": 7,
"sum": 0
},
"message": null,
"error": {
"message": null,
"errors": null
}
}
$result = Signalads::getCredit();
Sample Output
{
"data": {
"credit": 12345
},
"message": null,
"error": {
"message": null,
"errors": null
}
}
create your notification:
php artisan make:notification SendOtp
extend your notification from SignaladsNotification:
class SendOtp extends SignaladsNotification
{
}
overide the toSignalads function:
class SendOtp extends SignaladsNotification
{
public function __construct(Otp $otp)
{
$this->otp = $otp;
}
public function toSignalads($notifiable)
{
return (new SignaladsMessage("your verify code is $otp->code"))
->from('10004346');
}
}
you should add Notifiable trait and routeNotificationForSignalads method in your model
class Otp extends Model
{
use Notifiable;
public function routeNotificationForSignalads($driver, $notification = null)
{
return $this->number;
}
}
class SendWithPattern extends SignaladsBaseNotification
{
public function toSignalads(mixed $notifiable): SignaladsMessage
{
return (new SignaladsMessage(''))
->patternId(123412341234)
->patternParams([1,2])
->sendMethod(SignalSendMethods::sendPattern);
}
}
class SendWithPattern extends SignaladsBaseNotification
{
public function toSignalads(mixed $notifiable): SignaladsMessage
{
return (new SignaladsMessage('پیام تست'))
->to(["09191234567", "09191234567"])
->sendMethod(SignalSendMethods::sendGroup);
}
}
برای مطالعه بیشتر به صفحه معرفی وب سرویس اس ام اس سیگنال مراجعه نمایید .
درصورت مشاهده هرگونه اشکال در کارکرد پکیج میتوانید درخواست pull request کنید یا با ایمیل support@signalads.com با ما در ارتباط باشید.
How can I help you explore Laravel packages today?