Files
Qiniu/php-sdk/examples/sms/sms_query_send_sms.php
2026-02-23 19:48:13 +08:00

51 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once __DIR__ . '/../../autoload.php';
use Qiniu\Auth;
use Qiniu\Sms\Sms;
// 控制台获取密钥https://portal.qiniu.com/user/key
$accessKey = getenv('QINIU_ACCESS_KEY');
$secretKey = getenv('QINIU_SECRET_KEY');
$auth = new Auth($accessKey, $secretKey);
$client = new Sms($auth);
// 查询发送记录
// 参考文档https://developer.qiniu.com/sms/api/5852/query-send-sms
$job_id = 'xxxx'; // 发送任务返回的 id
$message_id = 'xxxx'; // 单条短信发送接口返回的 id
$mobile = 'xxxx'; // 接收短信的手机号码
// 短信的状态sending: 发送中success: 发送成功failed: 发送失败waiting: 等待发送
$status = 'success';
$template_id = 'xxxx'; // 模版 id
// marketing: 营销短信notification: 通知短信verification: 验证码类短信voice: 语音短信
$type = 'notification';
$start = 1599976580; // 开始时间
$end = 1599977229; // 结束时间
$page = 1; // 页码,默认为 1
$page_size = 20; // 每页返回的数据条数默认20最大200
list($ret, $err) = $client->querySendSms(
$job_id,
$message_id,
$mobile,
$status,
$template_id,
$type,
$start,
$end,
$page,
$page_size
);
echo "\n====> query send sms result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}