第一步:在\Application\Common\Common\function.php加入sendTemplateSMS 函数
代码:
/**
* 发送模板短信
* @param int $to 手机号
* @param int $datas 内容数据 格式为数组
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
* @return boole
*/
function sendTemplateSMS($to,$datas,$tempId)
{
//请求地址,格式如下,不需要写https://
$serverIP='app.cloopen.com';
//请求端口
$serverPort='8883';
//REST版本号
$softVersion='2013-12-26';
//主帐号
$accountSid=C('RONGLIAN_ACCOUNT_SID');
//主帐号Token
$accountToken=C('RONGLIAN_ACCOUNT_TOKEN');
//应用Id
$appId=C('RONGLIAN_APPID');
$rest = new\Org\wlw\Rest($serverIP,$serverPort,$softVersion);
$rest->setAccount($accountSid,$accountToken);
$rest->setAppId($appId);
// 发送模板短信
$result = $rest->sendTemplateSMS($to,array($datas,5),$tempId);
if($result == NULL ) {
return false;
}
if($result->statusCode!=0) {
return false;
}else{
return true;
}
}
第二步:把Rest.class.php文件复制到\ThinkPHP\Library\Org\wlw\
第三步:把参数配置写在Application\Common\Conf\config.php
/********lpj 短信配置*******/
'RONGLIAN_ACCOUNT_SID' => '', //容联云通讯 主账号 accountSid
'RONGLIAN_ACCOUNT_TOKEN' => '', //容联云通讯 主账号token accountToken
'RONGLIAN_APPID' => '', //容联云通讯 应用Id appid
'RONGLIAN_TEMPLATE_ID' => '', //容联云通讯 模板Id
);
验证和其他的需要自己写了,第一次发布没什么经验,以后会加强的,谢谢大家
