milan-sahana/mm-sms
发送短信
v1.0.1
2024-07-18 20:31 UTC
Requires
- php: >=7.3
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2024-09-19 03:52:54 UTC
README
一个简单的库,用于通过MM Sms服务发送短信
Mail Mantra SMS的官方PHP库:https://sms1.mailmantra.com/v2
在此了解如何开始以及如何使用MM Sms了解短信流程:https://sms1.mailmantra.com/v2
先决条件
- PHP 7.3及以上版本,至8.3
安装
- 如果你的项目使用composer,运行以下命令
composer require milan-sahana/mm-sms:1.*
- 如果你没有使用composer,从版本部分下载最新版本。
##注意:此PHP库遵循以下实践
- 在
MilanSahana\MmSms
命名空间下 - API抛出异常而不是返回错误
- 尽可能使用数组传递选项而不是多个参数
- 所有请求和响应都通过JSON进行通信
文档
MM SMS的API及其用法文档可在https://sms1.mailmantra.com找到
基本用法
使用auth_key
实例化MM Sms实例。您可以从仪表板应用程序(https://sms1.mailmantra.com/v2/sender_id/list_all)获取密钥
use MilanSahana\MmSms\Sms; $mmSMS = new Sms($auth_key);
资源可以通过$mmSMS
对象访问。所有方法调用遵循以下模式
// $mmSMS->function() to access the API //Example $mmSMS->send('9876543210', '1234 is Your OTP. Do not share with anyone.','123456789101112');
常见示例
查看余额
查看您的余额
use MilanSahana\MmSms\Sms; $mmSMS = new Sms("JFDG231HFDJ34KGH8438DSUG4FUD8SG"); $balance_arr = $mmSMS->balance(); var_dump($balance_arr);
输出
array(3) { ["status"]=> int(1) ["message"]=> string(1) "7" ["code"]=> string(6) "MMTEST" }
发送短信
向一个或多个手机号码(用逗号分隔的手机号码)发送短信
use MilanSahana\MmSms\Sms; $mmSMS = new Sms("JFDG231HFDJ34KGH8438DSUG4FUD8SG"); $send_report = $mmSMS->send('9876543210', '123456 is Your OTP. Do not share with anyone.','12345678901234567890'); var_dump($send_report);
输出
array(3) { ["status"]=> int(1) ["message"]=> string(25) "1 SMS send Successfully.." ["code"]=> string(24) "346772774568353130393036" }
发送批量短信
向一个或多个手机号码(用逗号分隔的手机号码)发送短信
use MilanSahana\MmSms\Sms; $mmSMS = new Sms("JFDG231HFDJ34KGH8438DSUG4FUD8SG"); $sms = [ [ 'message' =>'1234 Your OTP. Do not share with anyone.', 'to'=>[ '9999999999', '8888888888', ] ], [ 'message' =>'56789 Your OTP. Do not share with anyone.', 'to'=>[ '7777777777', '9876543210' ] ], ]; $send_bulk_report = $mmSMS->sendBulk($sms, '12345678901234567890'); var_dump($send_bulk_report);
输出
array(3) { ["status"]=> int(1) ["message"]=> string(25) "4 SMS send Successfully.." ["code"]=> string(24) "346772774163393934343834" }
变更日志
版本1.0.1由milan-sahana提供 - 测试
- 代码清理
- 修复了错误
- PHP 7.3及以上
- 添加了防止JSON错误的选项
版本1.0.0 - 稳定版本
- 查看余额
- 添加了批量发送短信
- 修复了发送短信的问题
- 更新了extra数组
- 更新版本模式。
x.y.z
x = Main version of the plugin
y = New features were added to the plugin
z = Fixes/patches to existing features of the plugin
许可
Razorpay PHP SDK在MIT许可下发布。有关详细信息,请参阅LICENSE文件。