example.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. require_once("../../autoload.php");
  3. use \Qiniu\Auth;
  4. $ak="xxxx";
  5. $sk="xxxx";
  6. $auth = new Auth($ak, $sk);
  7. $client = new Qiniu\Sms\Sms($auth);
  8. //发送信息模块
  9. $template_id="1131792074274775040";
  10. $mobiles=array("18011111111","18011111111");
  11. $code = array('code' => 'code' );
  12. try {
  13. //发送短信
  14. $resp = $client->sendMessage($template_id, $mobiles, $code);
  15. print_r($resp);
  16. } catch (\Exception $e) {
  17. echo "Error:", $e, "\n";
  18. }exit;
  19. //模板模块
  20. $name="tstest001";
  21. $template="tesy001 ${code}";
  22. $type="notification";
  23. $description="tstest001";
  24. $signature_id="1131464448834277376";
  25. $id="1131810682442883072";
  26. try {
  27. //创建模板
  28. $resp = $client->createTemplate($name, $template, $type, $description, $signature_id);
  29. print_r($resp);
  30. //查询模板
  31. $resp = $client->queryTemplate();
  32. print_r($resp);
  33. //修改模板
  34. $resp = $client->updateTemplate($id, $name, $template, $description, $signature_id);
  35. print_r($resp);
  36. //删除模板
  37. $resp = $client->deleteTemplate($id);
  38. print_r($resp);
  39. } catch (\Exception $e) {
  40. echo "Error:", $e, "\n";
  41. }
  42. //签名模块
  43. $signature = 'lfxlive2';
  44. $source = 'enterprises_and_institutions';
  45. $pic="/Users/Desktop/sss.jpg";
  46. $audit_status="passed";
  47. $page=1;
  48. $page_size=1;
  49. $id="1131464448834277376";
  50. try {
  51. //创建签名
  52. $resp = $client->createSignature($signature, $source, $pic);
  53. print_r($resp);
  54. //查询签名
  55. $resp = $client->checkSignature($audit_status);
  56. //修改签名
  57. $resp = $client->updateSignature($id, $signature, $source, $pic);
  58. print_r($resp);
  59. //删除ID
  60. $resp = $client->deleteSignature($id);
  61. print_r($resp);
  62. } catch (\Exception $e) {
  63. echo "Error:", $e, "\n";
  64. }