rapidsmsng/sms-php-sdk

Rapid SMS PHP SDK是为Rapid SMS - 批量短信应用而构建的

0.1.0 2020-06-16 19:32 UTC

This package is auto-updated.

Last update: 2024-09-25 12:05:39 UTC


README

Rapid SMS PHP SDK是为Rapid SMS - 批量短信应用而构建的

先决条件

要使用Rapid SMS SDK,您必须已在Rapid SMS中创建账户。有关更多详细信息,请访问:Rapid SMS

php >=7.2
Rapid SMS - Bulk SMS Application

安装

通过Composer

composer require rapidsmsng/sms-php-sdk 

以及通过Bash

git clone https://github.com/rapidsmsng/sms-php-sdk.git

用法

步骤1

如果使用Git Clone安装Rapid SMS SDK,则使用命名空间加载您的Rapid SMS SDK类文件。

require_once 'src/RapidSMS.php';
use RapidSMS\RapidSMS;

如果使用Composer安装Rapid SMS API,请在项目的index.php文件或您需要使用Rapid SMS SDK类的任何文件中require/include autoload.php文件:

require 'vendor/autoload.php';
use RapidSMS\RapidSMS;

步骤2

https://rapidsmsng.com/sms-api/info(在您的账户内)获取您的API_KEY

$apiKey = 'YWRtaW46YWRtaW4ucGFzc3dvcmQ=';

步骤3

更改您的发送者ID。在此处提交发送者ID以供批准:https://rapidsmsng.com/user/sms/sender-id-management

$from = 'RapidSMSNG';

步骤4

我们要发送到的号码 - 任何手机号码

$destination = '08028333008';

如果有多个号码,请在每个单独的号码后使用逗号(,)。

$destination = '08028333008,09054036811,09087040398';

您可以在单个API请求中使用逗号分隔的字符串插入最多100个号码。

步骤5

将您的URL替换为 https://rapidsmsng.com/sms/apisms/api是必需的。

$url = 'https://rapidsmsng.com/sms/api';

// SMS正文

$sms = 'Test message from RAPID SMS';

// Unicode SMS

$unicode = '1'; //For Unicode message

// 调度短信

$scheduleDate = '05/17/2020 10:20 AM'; //Date like this format: m/d/Y h:i A

// 为请求创建纯文本SMS正文

$smsBody = array(
    'api_key' => $apiKey,
    'to' => $destination,
    'from' => $from,
    'sms' => $sms
);

// 为请求创建Unicode SMS正文

$smsBody = array(
    'api_key' => $apiKey,
    'to' => $destination,
    'from' => $from,
    'sms' => $sms,
    'unicode' => $unicode,
);

// 为调度请求创建SMS正文

$smsBody = array(
    'api_key' => $apiKey,
    'to' => $destination,
    'from' => $from,
    'sms' => $sms,
    'schedule' => $scheduleDate,
);

步骤6

实例化一个新的Rapid SMS API请求

$client = new RapidSMS\RapidSMS();

发送短信

最后通过Rapid SMS API发送您的短信

$response = $client->sendSms($url, $smsBody);

获取收件箱

获取所有您的消息

$getInbox = $client->getInbox($apiKey, $url);

获取余额

获取您的账户余额

$getBalance = $client->checkBalance($apiKey, $url);

响应

Rapid SMS API以json格式返回响应,例如

{"code": "ok","message": "Successfully Send"}

投递报告

将投递报告推送到您指定的端点即将推出

状态码

作者