usmsgh / usmsgh-v3-api-sdk
Urhitech Bulk SMS V3 API 的 PHP SDK
v1.1.1
2023-11-29 14:46 UTC
Requires
- php: >=8.0
- ext-curl: *
- ext-json: *
README
Urhitech SMS PHP SDK 为 PHP 编写的应用程序提供了对 USMSGH API 的合适方法。它包括一组预定义的类和函数,这些类和函数从 API 响应中初始化自己。
该库还提供其他功能。例如
- 快速设置和使用的简单配置路径
- 分页辅助工具。
您可以在 usmsgh.com 注册 USMSGH 账户
先决条件
PHP ^8.0 及更高版本
安装
通过 Composer
$ composer require usmsgh/usmsgh-v3-api-sdk
通过 Git Bash
git clone https://github.com/majesty2017/usmsgh-v3-api-sdk.git
文档
请参阅 https://usmsgh.com/developer/ 获取最新文档
使用方法
步骤 1
如果您通过 Git Clone 安装 Urhitech SMS PHP SDK,则加载 Urhitech SMS PHP API 类文件并使用命名空间。
require_once '/path/to/src/Usms.php'; use Urhitech\Usms;
如果您通过 Composer 安装 Urhitech SMS PHP SDK,请在项目的 index.php 文件中或其他需要使用 Urhitech SMS PHP API 类的文件中要求 autoload.php 文件。
require __DIR__ . '/vendor/autoload.php'; use use Urhitech\Usms;
Urhitech SMS PHP SDK 端点是 RESTful 的,使用和返回 JSON。所有 Http 端点都需要在请求头中包含 API Key。
有关获取 API Key 的更多信息,请访问 此处 复制或生成新的密钥进行授权。
HTTP 端点
- https://webapp.usmsgh.com/api/v3/sms/send
- https://webapp.usmsgh.com/api/v3/sms/{uid}
- https://webapp.usmsgh.com/api/v3/sms
- https://webapp.usmsgh.com/api/v3/me
- https://webapp.usmsgh.com/api/v3/balance
- https://webapp.usmsgh.com/api/v3/contacts
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}/show/
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}/store
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}/search/{uid}
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}/update/{uid}
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}/delete/{uid}
- https://webapp.usmsgh.com/api/v3/contacts/{group_id}/all
步骤 2
实例化 UrhitechSMSPHPAPI
$client = new Urhitech\Usms;
发送短信
$api_key = "Enter Your API Key here"; $url = "https://webapp.usmsgh.com/api/v3/sms/send"; $recipients = "233500000000,233540000000"; $message = "Hello world"; $senderid = "Enter your approved sender ID here"; $response = $client->send_sms($url, $api_key, $senderid, $recipients, $message);
检查短信信用余额
$api_key = "Enter Your API Key here"; $url = "https://webapp.usmsgh.com/api/v3/balance"; $get_credit_balance = $client->check_balance($url, $api_key);
查看个人资料
$api_key = "Enter Your API Key here"; $url = "https://webapp.usmsgh.com/api/v3/me"; $get_profile = $client->profile($url, $api_key);