osonsms/gateway
Composer 安装命令:
composer require osonsms/gateway
包简介
A simple library for sending SMS via OsonSMS API.
关键字:
README 文档
README
Here you can find a short instruction of how to install and use this package.
Installation
You can install the package via composer:
composer require osonsms/gateway
Usage
Run following command to publish a migration file:
php artisan vendor:publish --provider="OsonSMS\OsonSMSService\OsonSmsServiceProvider" --tag="migrations"
Run php artisan migrate to create a necessary package table.
To create a config file in order to specify OsonSMS credentials run following command:
php artisan vendor:publish --provider="OsonSMS\OsonSMSService\OsonSmsServiceProvider" --tag="config"
Open config/osonsmsservice.php config file and specify following parameters:
- login - Your login in OsonSMS platform
- bearer_token - Your Bearer token from OsonSMS platform (obtained after registration)
- sender_name - SMS Sender Name assigned to you
Below you can find a console command created in Laravel in order to test OsonSMS service.
Create a command using php artisan make:command TestOsonSMSServiceCommand in order to create a test command. Find it in the project folder and copy paste following code.
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use JsonException; use OsonSMS\OsonSMSService\OsonSmsService; use RuntimeException; class TestOsonSMSServiceCommand extends Command { protected $signature = 'app:test-osonsms-service'; public function __construct(private readonly OsonSmsService $osonSmsService) { parent::__construct(); } public function handle(): void { try { // You need to provide senderName, phonenumber, message and txtId to sendSMS method in order to send SMS. $msgId = $this->osonSmsService->sendSMS( senderName: config('osonsmsservice.sender_name'), phonenumber: '927777777', message: 'Hello from Laravel. Your random code: ' . random_int(100, 1000), txnId: uniqid('test', true) ); echo "SMS sent successfully with msg_id: $msgId" . PHP_EOL; // This is how you can check the sms status using msgId returned from sendSMS method. sleep(5); // Intentionally sleeping for 5 seconds in order to get the more accurate sms delivery status echo "SMS Status: " . $this->osonSmsService->getSMSStatus($msgId) . PHP_EOL; // To get the balance of your account simply call getBalance() method echo "My Balance: " . $this->osonSmsService->getBalance() . PHP_EOL; } catch (RuntimeException|JsonException $exception) { echo $exception->getMessage() . PHP_EOL; } } }
Run php artisan app:test-osonsms-service in the terminal to see it in action,
don't forget to run previous commands to publish migration file and create config file.
You can find the logs of your SMS in the table called osonsms_log.
If you have any further questions or recommendations, feel free to send us an email at info@osonsms.com.
Security
If you discover any security related issues, please email i@bakhtiyor.tj instead of using the issue tracker.
Credits
osonsms/gateway 适用场景与选型建议
osonsms/gateway 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 758 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「smsgateway」 「osonsms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 osonsms/gateway 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 osonsms/gateway 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 osonsms/gateway 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is my take on a sms sender interface, that in time should support a lot of different sms gateways.
SMSGateway.Me for Laravel
config your sms gateway provider and start sending sms
smsgateway.me integration for Laravel
A simple library for sending SMS via OsonSMS API.
Effective Solutions (Pvt) Ltd. SMS Gateway Bundle
统计信息
- 总下载量: 758
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-06