haggag / msegat
Msegat SMS 提供商
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-08 20:23:01 UTC
README
关于 Msegat
沙特阿拉伯领先的 SMS 提供商,通过可靠的投递能力最大化您的覆盖范围。
功能
- 向多个接收者发送 SMS。
- 使用自定义发送者名称 ID 向多个接收者发送 SMS。
- 发送 OTP。
- 计算消息成本点。
- 发送者名称 ID 查询。
- 余额查询。
安装
composer require jodeveloper/msegat
发布仓库配置
php artisan vendor:publish --provider="jodeveloper\Msegat\MsegatServiceProvider"
这将发布 msegat.php 配置到 config/msegat.php。
准备环境
将以下配置添加到 .env 文件中。
MSEGAT_DEFAULT_SENDER="Type your default sender name" MSEGAT_USERNAME="Your Msegat Account Username" MSEGAT_API_KEY="Your API Key"
您可以从这个 URL 获取您的 API 密钥 MSEGAT,登录成功后。
用法
发送 SMS 消息
- 使用默认的发送者名称 ID 向多个接收者发送 SMS,该 ID 您已在 .env 文件中填写。
use jodeveloper\Msegat\Facades\Msegat; Msegat::numbers(['05xxxxxxxx', '05xxxxxxxx']) ->message('Hello World') ->sendWithDefaultSender();
- 使用 自定义 的发送者名称 ID 向多个接收者发送 SMS。
use jodeveloper\Msegat\Facades\Msegat; Msegat::numbers(['05xxxxxxxx', '05xxxxxxxx']) ->message('Hello World') ->sendWithSender('DigitalTunnel');
JSON 响应示例
{ "response": { "code": "1", "message": "Success" } }
OTP (一次性密码)
- 使用默认发送者名称 ID 发送 OTP 消息。
use jodeveloper\Msegat\Facades\Msegat; Msegat::numbers(['05xxxxxxxx']) ->sendOTP();
- 如果您想使用 OTP 发送者名称发送免费 OTP,可以将 'OTP' 传递给 sendOTP 方法。
use jodeveloper\Msegat\Facades\Msegat; Msegat::numbers(['05xxxxxxxx']) ->sendOTP('OTP');
JSON 响应示例
{ "response": { "code": "1", "message": "Success" }, "pin": "7693" }
查询
使用 Msegat 计算消息成本
use jodeveloper\Msegat\Facades\Msegat; Msegat::numbers(['9665xxxxxxxx', '9665xxxxxxxx', '9665xxxxxxxx']) ->message('Hello World') ->calculateCost();
JSON 响应示例
{ "total_numbers": 3, "point_cost": 2.75, "message_length": 23 }
获取所有发送者名称 ID
use jodeveloper\Msegat\Facades\Msegat; Msegat::getSenders();
JSON 响应示例
{ "response": [ { "SenderID": "Digital", "Status": "Refused" }, { "SenderID": "DigitalTunnel", "Status": "Activated" } ] }
获取账户余额
use jodeveloper\Msegat\Facades\Msegat; Msegat::getBalance();
JSON 响应示例
{ "response": { "balance": 964795 } }
错误代码
-
1 - 成功
-
M0000 - 成功
-
M0001 - 变量缺失
-
M0002 - 无效的登录信息
-
M0022 - 超过允许的发送者数量
-
M0023 - 发送者名称正在激活或拒绝激活
-
M0024 - 发送者名称应为英文或数字
-
M0025 - 发送者名称长度无效
-
M0026 - 发送者名称已激活或未找到
-
M0027 - 激活码不正确
-
1010 - 变量缺失
-
1020 - 无效的登录信息
-
1050 - MSG 主体为空
-
1060 - 余额不足
-
1061 - MSG 重复
-
1064 - 免费OTP,无效的 MSG 内容,您应该使用 "Pin Code is: xxxx" 或 "Verification Code: xxxx" 或 "رمز التحقق: 1234",或升级您的账户并激活您的发送者以发送任何内容
-
1110 - 发送者名称缺失或不正确
-
1120 - 手机号码不正确
-
1140 - MSG 长度太长
-
M0029 - 无效的发送者名称 - 发送者名称应只包含字母、数字,且最大长度应为 11 个字符
-
M0030 - 发送者名称应以 AD 结尾
-
M0031 - 上传文件的最大允许大小为 5 MB
-
M0032 - 只允许 pdf、png、jpg 和 jpeg 文件
-
M0033 - 发送者类型应为普通或白名单
-
M0034 - 请使用 POST 方法
-
M0036 - 没有发送者
许可证
Msegat 包是开源软件,许可协议为 MIT 许可。