signalads-co/laravel
Composer 安装命令:
composer require signalads-co/laravel
包简介
laravel signalads integration
关键字:
README 文档
README
First of all you will ned an API Key . You can get one Here.
Supported Laravel Versions:
| Laravel Version | Support |
|---|---|
| 3.0 | 💔 |
| 4.0 | ✅ |
| 5.0 | ✅ |
| 6.0 | ✅ |
| 7.0 | ✅ |
| 8.0 | ✅ |
| 9.0 | ✅ |
We highly recomment you to always use the latest version of laravel
Installation
Step 1 - Install the package
- Method 1: You can install signalads/laravel with Composer directly in your project:
composer require signalads-co/laravel
- Method 2: Add this line to Composer.json file in your project
"signalads/laravel": "*"
Then run following command to download extension using composer
$ composer update
Step 2 - Publish
Run this command in your project dirctory:
php artisan vendor:publish --tag=signalads-laravel
Step 3 - Api-Key
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' => '',
];
Usage
You can use the package where ever you want.
- First use the class:
use Signalads\Laravel\Facade\Signalads;
- Exception Handler
try { // call SignalAdsApi function } catch(\SignalAds\Exceptions\ApiException $e){ // در صورتی که خروجی وب سرویس 200 نباشد این خطا رخ می دهد echo $e->errorMessage(); } catch(\SignalAds\Exceptions\HttpException $e){ // در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد echo $e->errorMessage(); }
- Send Single SMS
$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
}
}
- Send Multiple SMS With Same Text
$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
}
}
- Send Sms With Pattern
$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
}
}
- Get Message Status
Statuses
PENDING = 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
}
}
- Get account credit
$result = Signalads::getCredit();
Sample Output
{
"data": {
"credit": 12345
},
"message": null,
"error": {
"message": null,
"errors": null
}
}
Usage in Notifications
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; } }
- Send With Pattern
class SendWithPattern extends SignaladsBaseNotification { public function toSignalads(mixed $notifiable): SignaladsMessage { return (new SignaladsMessage('')) ->patternId(123412341234) ->patternParams([1,2]) ->sendMethod(SignalSendMethods::sendPattern); } }
- Send Group
class SendWithPattern extends SignaladsBaseNotification { public function toSignalads(mixed $notifiable): SignaladsMessage { return (new SignaladsMessage('پیام تست')) ->to(["09191234567", "09191234567"]) ->sendMethod(SignalSendMethods::sendGroup); } }
اطالاعات بیشتر
برای مطالعه بیشتر به صفحه معرفی وب سرویس اس ام اس سیگنال مراجعه نمایید .
درصورت مشاهده هرگونه اشکال در کارکرد پکیج میتوانید درخواست pull request کنید یا با ایمیل support@signalads.com با ما در ارتباط باشید.
signalads-co/laravel 适用场景与选型建议
signalads-co/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sms」 「laravel」 「signalads」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 signalads-co/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 signalads-co/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 signalads-co/laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
yii2-sms expand
Alfabank REST API integration
A fork of simplesoftwareio/simple-sms with Verimor driver.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-29