liagkos/yuboto-sms

Yuboto SMS API 消费者

v1.0.1 2020-09-25 13:58 UTC

This package is auto-updated.

Last update: 2024-09-13 21:19:20 UTC


README

  • 为 PHP >= 7 编写
  • 易于解析结果
  • 基于 OMNI API 文档 v1.2
  • 使用 Guzzle 进行通信
  • 使用 Carbon 进行日期处理

为什么写这个

我想使用 Guzzle,并且想使用 IDE 自动完成功能。没有其他原因,API 非常简单易用,即使没有我的库也可以。

安装

使用 Composer 安装包

composer require liagkos/yuboto-sms

用法

use Liagkos\SMS\Yuboto\Request;

require_once 'vendor/autoload.php';

$token   = 'API-token';
$command = 'Command';
$params  = ['param1' => 'value1', 'param2' => 'value2'];

$response = Request::exec($token, $command, $params);

if ($response['success']) {
    print_r(Response::<ResponseObject>($response['response']));
} else {
    echo 'Error (' . $response['type'] . '): ' . $response['msg'] . ' ('. $response['code'] .')';
}

详细信息

  • $token 是从 Yuboto 收到的 API 令牌
  • $command区分大小写 的,可能是以下之一
    • Send - 发送 SMS/Viber 消息
    • Dlr - 实时检索消息状态
    • Cost - 检索每个国家/网络的费用信息
    • CostDetails - 检索每个网络的费用信息
    • Balance - 检查您的余额
    • Cancel - 取消计划中的消息
    • CreateKey - 创建子用户 API 密钥
    • verifypin - 验证 TFA 消息的 PIN
    • DlrPhonenumber - 获取特定电话号码已发送消息的详细信息
  • $params 是 null 或特定命令的参数
  • 响应区分大小写 的,可能是以下之一
    • Send - 用于 Send 命令
    • Dlr - 用于 Dlr 命令
    • Cost - 用于 Cost 命令
    • CostDetails - 用于 CostDetails 命令
    • Balance - 用于 Balance 命令
    • Cancel - 用于 Cancel 命令
    • CreateKey - 用于 CreateKey 命令
    • VerifyPin - 用于 verifypin 命令
    • DlrPhonenumber - 用于 DlrPhonenumber 命令

请参阅 tech-specs 文件夹中的 PDF 指南,以获取关于命令和参数的详细信息。在这里重复文档没有意义。

响应

  • $response['success'] = false - 错误
    • $response['type'] = comm|api
    • $respone['msg'] = 错误信息
    • $response['code'] = 错误代码
  • $response['success'] == true - OK
    • $reponse['response'] = Guzzle Body Object

其他信息

  • 所有响应都是 \Liagkos\SMS\Yuboto\Object\Something 对象,在 Object 文件夹中定义,遵循 API 定义
  • DlrDlrPhonenumber 命令的 submitDatedlrDateCarbon 日期对象

最后

我与 Yuboto 没有关系,Yuboto 字是他们的注册商标。我对程序的不当使用或任何损害或损失不承担责任,包括财务损害或损失。使用风险自负。