<?php
/*
 *  Copyright (c) 2014 The CCP project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
 *  that can be found in the LICENSE file in the root of the web site.
 *
 *   http://www.yuntongxun.com
 *
 *  An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

/**
  * 发送模板短信
  * @param to 手机号码集合,用英文逗号分开
  * @param datas 内容数据 格式为数组 例如：array('Marry','Alon')，如不需替换请填 null
  * @param $tempId 模板Id
  */       
function sendSMS($to,$datas,$tempId)
{
    //主帐号
    $accountSid = '8a48b5514ff923b4014ffe4f7d570d2c';

    //主帐号Token
    $accountToken = '28953ff4d46c492f90329cda3ce473ad';

    //应用Id
    $appId = '8a48b5515018a0f4015059a74f0f7565';

    //请求地址，格式如下，不需要写https://
    $serverIP = 'app.cloopen.com';

    //请求端口 
    $serverPort = '8883';

    //REST版本号
    $softVersion = '2013-12-26';
    // 初始化REST SDK
     //global $accountSid,$accountToken,$appId,$serverIP,$serverPort,$softVersion;
     $rest = new REST($serverIP,$serverPort,$softVersion);
     $rest->setAccount($accountSid,$accountToken);
     $rest->setAppId($appId);
    
     // 发送模板短信
     $result = $rest->sendTemplateSMS($to,$datas,$tempId);
     if($result == NULL ) {
         return -1;
     }

     return intval($result->statusCode);
}
?>
