SmsClientSample.php 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. include 'BaiduBce.phar';
  3. require 'SampleConf.php';
  4. use BaiduBce\Services\Sms\SmsClient;
  5. global $SMS_TEST_CONFIG;
  6. $client = new SmsClient($SMS_TEST_CONFIG);
  7. // 手机号,支持单个或多个手机号,多个手机号之间以英文逗号分隔,e.g. 13800138000,13800138001,一次请求最多支持200个手机号
  8. $mobile = '17615151711';
  9. // 模板编码
  10. $template = 'sms-tmpl-VlYLOm62611';
  11. // 签名
  12. $signatureId = 'sms-sign-yxveGQ86111';
  13. // 模板内容
  14. $contentVar = array(
  15. 'content' => '验证码有效期5min'
  16. );
  17. /**
  18. *
  19. * 响应数据格式
  20. *
  21. *{
  22. * "requestId":"ac17060505d4453ca1c9a7c5be82042b",
  23. * "code":"1000",
  24. * "message":"成功",
  25. * "data":[
  26. * {
  27. * "code":"1000",
  28. * "message":"成功",
  29. * "mobile":"13800138000",
  30. * "messageId":"6edf7cffa7434d2e8335a0d021ee2b2f"
  31. * }
  32. * ]
  33. *}
  34. */
  35. $response = $client->sendMessage($mobile, $signatureId, $template, $contentVar);
  36. print_r($response);