SendSMS.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * Copyright (c) 2014 The CCP project authors. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
  6. * that can be found in the LICENSE file in the root of the web site.
  7. *
  8. * http://www.yuntongxun.com
  9. *
  10. * An additional intellectual property rights grant can be found
  11. * in the file PATENTS. All contributing project authors may
  12. * be found in the AUTHORS file in the root of the source tree.
  13. */
  14. /**
  15. * 发送模板短信
  16. * @param to 手机号码集合,用英文逗号分开
  17. * @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
  18. * @param $tempId 模板Id
  19. */
  20. function sendSMS($to,$datas,$tempId)
  21. {
  22. //主帐号
  23. $accountSid = '8a48b5514ff923b4014ffe4f7d570d2c';
  24. //主帐号Token
  25. $accountToken = '28953ff4d46c492f90329cda3ce473ad';
  26. //应用Id
  27. $appId = '8a48b5515018a0f4015059a74f0f7565';
  28. //请求地址,格式如下,不需要写https://
  29. $serverIP = 'app.cloopen.com';
  30. //请求端口
  31. $serverPort = '8883';
  32. //REST版本号
  33. $softVersion = '2013-12-26';
  34. // 初始化REST SDK
  35. //global $accountSid,$accountToken,$appId,$serverIP,$serverPort,$softVersion;
  36. $rest = new REST($serverIP,$serverPort,$softVersion);
  37. $rest->setAccount($accountSid,$accountToken);
  38. $rest->setAppId($appId);
  39. // 发送模板短信
  40. $result = $rest->sendTemplateSMS($to,$datas,$tempId);
  41. if($result == NULL ) {
  42. return -1;
  43. }
  44. return intval($result->statusCode);
  45. }
  46. ?>