swiftsmsgh/swiftsmsgh-api-sdk

Swiftsms-GH 大量短信 API 的 PHP SDK

v1.0.0 2024-01-19 13:30 UTC

This package is auto-updated.

Last update: 2024-09-19 16:03:16 UTC


README

Swiftsms-GH PHP SDK 为使用 PHP 编写的应用程序提供了对 Swiftsms-GH API 的合适方法。它包括一组预定义的类和函数,这些类和函数从 API 响应中初始化自己。

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

  1. 易于配置路径,快速设置和使用
  2. 分页助手。

您可以在 swiftsmsgh.com 上注册 Swiftsms-GH 账户

先决条件

PHP ^8.0 及更高版本

安装

通过 Composer

$ composer require swiftsmsgh/swiftsmsgh-api-sdk

通过 Git Bash

git clone https://github.com/majesty-scofield/swiftsmsgh-api-sdk.git

文档

请参阅 https://swiftsmsgh.com/developer 以获取最新文档

使用方法

步骤 1

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

require_once '/path/to/src/Swiftsmsgh.php';
use Swiftsms\Swiftsmsgh;

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

require __DIR__ . '/vendor/autoload.php';
use Swiftsms\Swiftsmsgh;

Swiftsms-GH PHP SDK 端点是 RESTful 的,消耗和返回 JSON。所有 Http 端点都需要在请求头中包含 API 密钥。

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

HTTP 端点

步骤 2

实例化 SwiftsmsghSMSSDKAPI

$api_token = "Enter Your API Token here";

$sender_id = "Enter your approved Sender ID here";

$client = new Swiftsmsgh\SwiftsmsghSMS($api_token, $sender_id);

发送短信

$recipients = "233500000000,233540000000";

$message = "This is a test message";

$response = $client->send_sms($recipients, $message);

检查短信余额

$url = "https://app.swiftsmsgh.com/api/v3/balance";

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

查看个人资料

$url = "https://app.swiftsmsgh.com/api/v3/me";

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

状态码