supreme / usmsgh-api-sdk

Urhitech Bulk SMS API 的 PHP SDK

v1.0.3 2023-01-20 13:32 UTC

This package is auto-updated.

Last update: 2024-09-20 17:27:33 UTC


README

Urhitech SMS API SDK 为 PHP 编写的应用程序提供了对 USMSGH API 的合适方法。它包括一组预定义的类和函数,用于 API 资源,这些类和函数会从 API 响应中初始化自身。

该库还提供其他功能。例如

  1. 快速设置和使用的便捷配置路径
  2. 分页助手。

您现在可以前往 usmsgh.com 注册 USMSGH 账户

先决条件

PHP 5.6.0 及更高版本

安装

通过 Composer

$ composer require supreme/usmsgh-api-sdk

通过 Git Bash

git clone https://github.com/urhitech/usmsgh-api-sdk.git

文档

请参阅 https://usmsgh.com/developer/ 获取最新的文档

使用方法

步骤 1

如果您通过 Git Clone 安装 Urhitech SMS API SDK,请加载 Urhitech SMS PHP API 类文件并使用命名空间。

require_once '/path/to/src/Usmsgh.php';
use Urhitec\Usms;

如果您通过 Composer 安装 Urhitech SMS API SDK,请在您的项目 index.php 或您需要使用 Urhitech SMS PHP API 类的任何文件中引入 autoload.php 文件。

require __DIR__ . '/vendor/autoload.php';
use use Urhitec\Usms;;

Urhitech SMS API SDK 端点是 RESTful 的,并消费和返回 JSON。所有 Http 端点都需要在请求头中包含 API 密钥。

有关获取 API 密钥的更多信息,请访问 此处 复制或生成新的密钥进行授权。

HTTP 端点

步骤 2

实例化 Urhitech SMS PHP API

$client = new Urhitec\Usms;

发送短信

$api_key = "Enter Your API Key here";

$url = "https://webapp.usmsgh.com/api/sms/send";

$recipients = "233500000000,233540000000";
$message = "Hello world";
$senderid = "Enter your approved sender ID here";

$response = $client->sendSMS($url, $api_key, $senderid, $recipients, $message);

检查短信余额

$api_key = "Enter Your API Key here";

$url = "https://webapp.usmsgh.com/api/balance";

$get_credit_balance = $client->check_balance($url, $api_key);

查看个人资料

$api_key = "Enter Your API Key here";

$url = "https://webapp.usmsgh.com/api/me";

$get_profile = $client->profile($url, $api_key);