No Description

sms_query_send_sms.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. require_once __DIR__ . '/../../autoload.php';
  3. use Qiniu\Auth;
  4. use Qiniu\Sms\Sms;
  5. // 控制台获取密钥:https://portal.qiniu.com/user/key
  6. $accessKey = getenv('QINIU_ACCESS_KEY');
  7. $secretKey = getenv('QINIU_SECRET_KEY');
  8. $auth = new Auth($accessKey, $secretKey);
  9. $client = new Sms($auth);
  10. // 查询发送记录
  11. // 参考文档:https://developer.qiniu.com/sms/api/5852/query-send-sms
  12. $job_id = 'xxxx'; // 发送任务返回的 id
  13. $message_id = 'xxxx'; // 单条短信发送接口返回的 id
  14. $mobile = 'xxxx'; // 接收短信的手机号码
  15. // 短信的状态,sending: 发送中,success: 发送成功,failed: 发送失败,waiting: 等待发送
  16. $status = 'success';
  17. $template_id = 'xxxx'; // 模版 id
  18. // marketing: 营销短信,notification: 通知短信,verification: 验证码类短信,voice: 语音短信
  19. $type = 'notification';
  20. $start = 1599976580; // 开始时间
  21. $end = 1599977229; // 结束时间
  22. $page = 1; // 页码,默认为 1
  23. $page_size = 20; // 每页返回的数据条数,默认20,最大200
  24. list($ret, $err) = $client->querySendSms(
  25. $job_id,
  26. $message_id,
  27. $mobile,
  28. $status,
  29. $template_id,
  30. $type,
  31. $start,
  32. $end,
  33. $page,
  34. $page_size
  35. );
  36. echo "\n====> query send sms result: \n";
  37. if ($err !== null) {
  38. var_dump($err);
  39. } else {
  40. var_dump($ret);
  41. }