ditsly / dits-sms-api
DITS SMS API 是为 DITS SMS - 营销用的大批量短信应用而构建的。
Requires
- php: >=5.3.0
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-05 10:31:30 UTC
README
DITS SMS API 是为 DITS SMS - 营销用的大批量短信应用而构建的。
先决条件
要运行 DITS SMS API,您必须在服务器上安装 DITS SMS 应用程序。
php >=5.6
DITS SMS - Bulk SMS Application For Markting
安装
通过 Composer
composer require ditsly/dits-sms-api
和通过 Bash
git clone https://github.com/dits/dits-sms-api.git
用法
步骤 1
如果使用 Git Clone 安装 DITS SMS API,则加载您的 DITS SMS API 类文件并使用命名空间。
require_once 'src/Class_DITS_SMS_API.php'; use DitsSMS\DitsSMSAPI;
如果使用 Composer 安装 DITS SMS API,则将 autoload.php 文件包含在您的项目 index.php 或您需要使用 DITS SMS API 类的任何文件中:
require 'vendor/autoload.php'; use DitsSMS\DitsSMSAPI;
步骤 2
从 https://sms.dits.ly/sms-api/info
设置您的 API_KEY。
$api_key = 'YWRtaW46YWRtaW4ucGFzc3dvcmQ=';
步骤 3
更改下面的发送者 ID。它可以是一个有效的发送者 ID。
$from = 'DITS';
步骤 4
我们要发送到的号码 - 任何电话号码
$destination = '21892XXXXXXX';
对于多个号码,请在每个单独的号码后使用逗号 (,)。
$destination = '21892XXXXXXX,21891XXXXXXX,21892XXXXXXX,21892XXXXXXX';
您可以在单个 API 请求中使用逗号插入最多 100 个号码。
您必须在电话号码的开头包含国家代码。
步骤 5
$url = 'https://sms.dits.ly/sms/api';
// 短信正文
$sms = 'Test Message From DITS SMS';
// Unicode 短信
$unicode = '1'; //For Unicode message
// 语音短信
$voice = '1'; //For voice message
// 安排短信
$schedule_date = '02/17/2021 10:20 AM'; //Date like this format: m/d/Y h:i A
// 为请求创建纯文本短信正文
$sms_body = array( 'api_key' => $api_key, 'to' => $destination, 'from' => $from, 'sms' => $sms );
// 为请求创建 Unicode 短信正文
$sms_body = array( 'api_key' => $api_key, 'to' => $destination, 'from' => $from, 'sms' => $sms, 'unicode' => $unicode, );
// 为请求创建语音短信正文
$sms_body = array( 'api_key' => $api_key, 'to' => $destination, 'from' => $from, 'sms' => $sms, 'voice' => $voice, );
// 为请求创建 MMS 短信正文
$sms_body = array( 'api_key' => $api_key, 'to' => $destination, 'from' => $from, 'sms' => $sms, //optional 'mms' => $mms, 'media_url' => $media_url, );
// 为请求创建安排短信正文
$sms_body = array( 'api_key' => $api_key, 'to' => $destination, 'from' => $from, 'sms' => $sms, 'schedule' => $schedule_date, );
步骤 6
实例化一个新的 DITS SMS API 请求
$client = new DitsSMSAPI();
发送短信
最后,通过 DITS SMS API 发送您的短信
$response = $client->send_sms($sms_body, $url);
获取收件箱
获取您所有的消息
$get_inbox=$client->get_inbox($api_key,$url);
获取余额
获取您的账户余额
$get_balance=$client->check_balance($api_key,$url);
响应
DITS SMS API 以 json
格式返回响应,例如
{"code":"ok","message":"Successfully Send"}
状态码
作者
- Dimensions Technology - 初始工作 - ditsly