shipu/muthofun-sms-gateway
Composer 安装命令:
composer require shipu/muthofun-sms-gateway
包简介
PHP client for MuthoFun SMS Payment Gateway API
README 文档
README
muthofun-sms-gateway is a PHP client for MUTHOFUN SMS Gateway API. This package is also support Laravel and Lumen.
Installation
Go to terminal and run this command
composer require shipu/muthofun-sms-gateway
Wait for few minutes. Composer will automatically install this package for your project.
For Laravel
Below Laravel 5.5 open config/app and add this line in providers section
Shipu\MuthoFun\MuthoFunServiceProvider::class,
For Facade support you have add this line in aliases section.
'MUTHOFUN' => Shipu\MuthoFun\Facades\MuthoFun::class,
Then run this command
php artisan vendor:publish --provider="Shipu\MuthoFun\MuthoFunServiceProvider"
Configuration
This package is required two configurations.
- username = your username which provide by MUTHOFUN.
- password = your password which provide by MUTHOFUN
muthofun-sms-gateway is take an array as config file. Lets services
use Shipu\MuthoFun\MUTHOFUN; $config = [ 'username' => 'Your Username', 'password' => 'Your Password' ]; $sms = new MUTHOFUN($config);
For Laravel
This package is also support Laravel. For laravel you have to configure it as laravel style.
Go to app\muthofun.php and configure it with your credentials.
return [ 'username' => 'Your Username', 'password' => 'Your Password' ];
Usages
Its very easy to use. This packages has a lot of functionalities and features.
Send SMS to a single user
In PHP:
use \Shipu\MuthoFun\MuthoFun; ... $sms = new MUTHOFUN($config); $response = $sms->message('your text here !!!', '01606022000')->send(); // Guzzle Response with request data // For another example please see below laravel section. return $response->autoParse(); // Getting only response contents.
In Laravel:
use \Shipu\MuthoFun\Facades\MuthoFun; ... $sms = MUTHOFUN::message('your text here !!!', '01606022000')->send(); // Guzzle Response with request data // or $sms = MUTHOFUN::message('your text here !!!')->to('01606022000')->send(); // or $sms = MUTHOFUN::send( [ 'message' => "your text here", 'to' => '01616022000' ] ); return $sms->autoParse(); // Getting only response contents.
Send same message to all users
$sms = MUTHOFUN::message('your text here !!!') ->to('01616022669') ->to('01845736124') ->to('01745987364') ->send(); // or you can try below statements also $sms = MUTHOFUN::message('your text here !!!', '01616022669') ->to('01845736124') ->to('01745987364') ->send(); // or $users = [ '01616022669', '01845736124', '01745987364' ]; $sms = MUTHOFUN::message('your text here !!!',$users)->send();
Send SMS to more user
$sms = MUTHOFUN::message('your text here one !!!')->to('01616022669') ->message('your text here two !!!')->to('01845736124') ->message('your text here three !!!')->to('01745987364') ->send(); // or $sms = MUTHOFUN::message('your text here one !!!', '01616022669') ->message('your text here two !!!', '01845736124') ->message('your text here three !!!', '01745987364') ->send(); // or $sms = MUTHOFUN::send([ [ 'message' => "your text here one !!!", 'to' => '01616022669' ], [ 'message' => "your text here two !!!", 'to' => '01707722669' ], [ 'message' => "your text here three !!!", 'to' => '01745987364' ] ]); // or $sms = MUTHOFUN::message('your text here one !!!', '01616022669')->send([ [ 'message' => "your text here two !!!", 'to' => '01707722669' ], [ 'message' => "your text here three !!!", 'to' => '01745987364' ] ]);
Send SMS with SMS template
Suppose you have to send SMS to multiple users but you want to mentions their name dynamically with message. So what can you do? Ha ha this package already handle this situations. Lets see
$users = [ ['01670420420', ['Nahid', '1234']], ['01970420420', ['Rana', '3213']], ['01770420420', ['Shipu', '5000']], ['01570420420', ['Kaiser', '3214']], ['01870420420', ['Eather', '7642']] ] $sms = new \Shipu\MuthoFun\MUTHOFUN(config('muthofun')); $msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send(); // or $users = [ '01670420420' => ['Nahid', '1234'], '01970420420' => ['Rana', '3213'], '01770420420' => ['Shipu', '5000'], '01570420420' => ['Kaiser', '3214'], '01870420420' => ['Eather', '7642'] ] $sms = new \Shipu\MuthoFun\MUTHOFUN(config('muthofun')); $msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send();
Here this messege will sent as every users with his name and promo code like:
8801670420420- Hello Nahid , Your promo code is: 12348801970420420- Hello Rana , Your promo code is: 32138801770420420- Hello Shipu , Your promo code is: 50008801570420420- Hello Kaiser , Your promo code is: 12348801870420420- Hello Eather , Your promo code is: 7642
Change Number Prefix
$sms = MUTHOFUN::numberPrefix('91')->message('your text here !!!', '01606022000')->send();
Default number prefix is 88;
Debugging
$sms = MUTHOFUN::debug(true)->message('your text here !!!', '01606022000')->send();
Default value is false. When debug true it's stop sending SMS and return sending query strings.
Response Data auto parse
$sms = MUTHOFUN::autoParse(true)->message('your text here !!!', '01606022000')->send();
Default value is false.
Disable Template
$sms = MUTHOFUN::template(false)->message('your text here !!!', '01606022000')->send();
Default value is true.
Response Data
$sms->autoParse();
Response :
SimpleXMLElement {#212 ▼
+"sms": SimpleXMLElement {#216 ▼
+"smsclientid": "713231739"
+"messageid": "500930552"
+"mobile-no": "+8801616022669"
}
Highly inspired by Apiz Package and Sslwireless SMS Gateway
Special Thanks to Salahuddin Rana
Support on Beerpay
Hey dude! Help me out for a couple of 🍻!
shipu/muthofun-sms-gateway 适用场景与选型建议
shipu/muthofun-sms-gateway 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 393 次下载、GitHub Stars 达 24, 最近一次更新时间为 2017 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「sms」 「gateway」 「laravel」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shipu/muthofun-sms-gateway 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shipu/muthofun-sms-gateway 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shipu/muthofun-sms-gateway 相关的其它包
同方向 / 同关键字的高下载量 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.
统计信息
- 总下载量: 393
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-19