send_sms_helper.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. require_once __MYDIR__.'/application/libraries/CCPRestSmsSDK.php';
  15. // require_once __MYDIR__.'\\application\\libraries\\CCPRestSmsSDK.php';
  16. //主帐号,对应开官网发者主账号下的 ACCOUNT SID
  17. $accountSid= '8a216da854ebfcf70154f57e5bd909c6';
  18. //主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
  19. $accountToken= '350c0bb396da4b018c1b07b6e14d3113';
  20. //应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
  21. //在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
  22. $appId='8a216da854ebfcf70154f57e5c3209cc';
  23. //请求地址
  24. //沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
  25. //生产环境(用户应用上线使用):app.cloopen.com
  26. $serverIP='https://sandboxapp.cloopen.com';
  27. //请求端口,生产环境和沙盒环境一致
  28. $serverPort='8883';
  29. //REST版本号,在官网文档REST介绍中获得。
  30. $softVersion='2013-12-26';
  31. /**
  32. * 发送模板短信
  33. * @param to 手机号码集合,用英文逗号分开
  34. * @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
  35. * @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
  36. */
  37. function sendTemplateSMS($to,$datas,$tempId)
  38. {
  39. // 初始化REST SDK
  40. // $accountSid= 'aaf98f894f16fdb7014f1baabe7a0697';测试
  41. $accountSid = '8a216da854ebfcf70154f57e5bd909c6';
  42. //主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
  43. //$accountToken= 'd43e9a2c1ab3447ab8c38550e9340910';测试
  44. $accountToken= '350c0bb396da4b018c1b07b6e14d3113';
  45. //应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
  46. //在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
  47. $appId='8a216da854ebfcf70154f57e5c3209cc';
  48. //请求地址
  49. //沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
  50. //生产环境(用户应用上线使用):app.cloopen.com
  51. // $serverIP='sandboxapp.cloopen.com';
  52. $serverIP='app.cloopen.com';
  53. //请求端口,生产环境和沙盒环境一致
  54. $serverPort='8883';
  55. //REST版本号,在官网文档REST介绍中获得。
  56. $softVersion='2013-12-26';
  57. $rest = new REST($serverIP,$serverPort,$softVersion);
  58. $rest->setAccount($accountSid,$accountToken);
  59. $rest->setAppId($appId);
  60. // 发送模板短信
  61. $result = $rest->sendTemplateSMS($to,$datas,$tempId);
  62. if($result == NULL ) {
  63. return false;
  64. }
  65. if($result->statusCode!=0) {
  66. return false;
  67. }else{
  68. return true;
  69. }
  70. }
  71. ?>