本文整理汇总了PHP中REST::sendTemplateSMS方法的典型用法代码示例。如果您正苦于以下问题:PHP REST::sendTemplateSMS方法的具体用法?PHP REST::sendTemplateSMS怎么用?PHP REST::sendTemplateSMS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类REST
的用法示例。
在下文中一共展示了REST::sendTemplateSMS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
//global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
//主帐号,对应开官网发者主账号下的 ACCOUNT SID
$accountSid = '8a48b5514a51d087014a56d235c4034a';
//主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
$accountToken = '2922e8361b734b64a6a917c110755f4b';
//应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
//在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
$appId = '8a48b5514a61a814014a7a16517e0ea0';
//请求地址
//沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
//生产环境(用户应用上线使用):app.cloopen.com
$serverIP = 'app.cloopen.com';
//请求端口,生产环境和沙盒环境一致
$serverPort = '8883';
//REST版本号,在官网文档REST介绍中获得。
$softVersion = '2013-12-26';
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
//echo "Sending TemplateSMS to $to <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
return $result;
}
示例2: sendTemplateSMS
/**
* 发送短信接口
* @param [type] $to [description]
* @param [type] $datas [description]
* @param [type] $tempId [description]
* @return [type] [description]
*/
private function sendTemplateSMS($to, $datas, $tempId)
{
import("Common.Util.CCPRestSmsSDK");
// 初始化REST SDK
$rest = new \REST(C('smsServerIP'), C('smsServerPort'), C('smsSoftVersion'));
$rest->setAccount(C('smsAccountSid'), C('smsAccountToken'));
$rest->setAppId(C('smsAppId'));
// 发送模板短信
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
$this->return['code'] = 1003;
$this->return['message'] = "result error!";
break;
}
if ($result->statusCode != 0) {
$this->return['code'] = intval($result->statusCode);
$this->return['message'] = "error msg :" . $result->statusMsg;
//TODO 添加错误处理逻辑
} else {
// 获取返回信息
$smsmessage = (array) $result->TemplateSMS;
$this->return['data']["dateCreated"] = $smsmessage['dateCreated'];
$this->return['data']["smsMessageSid"] = $smsmessage['smsMessageSid'];
//TODO 添加成功处理逻辑
}
$this->goJson($this->return);
}
示例3: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
echo "Sending TemplateSMS to {$to} <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
return array('sign' => 0, 'msg' => 'result error!');
}
if ($result->statusCode != 0) {
//echo "模板短信发送失败!<br/>";
//echo "error code :" . $result->statusCode . "<br>";
//echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
return array('sign' => 2, 'msg' => "error code :" . $result->statusCode . "-----error msg :" . $result->statusMsg);
} else {
//echo "模板短信发送成功!<br/>";
// 获取返回信息
//$smsmessage = $result->TemplateSMS;
//echo "dateCreated:".$smsmessage->dateCreated."<br/>";
//echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
//TODO 添加成功处理逻辑
return array('sign' => 1, 'msg' => "success");
}
}
示例4: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
//echo "Sending TemplateSMS to $to <br/>";
$output = array('return' => 0);
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
//echo "result error!";
//break;
}
if ($result->statusCode != 0) {
//echo "error code :" . $result->statusCode . "<br>";
//echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
if ($result->statusCode == 160021) {
$output['return'] = 1;
}
} else {
//echo "Sendind TemplateSMS success!<br/>";
// 获取返回信息
//$smsmessage = $result->TemplateSMS;
//echo "dateCreated:".$smsmessage->dateCreated."<br/>";
//echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
//TODO 添加成功处理逻辑
$output['return'] = 1;
}
echo json_encode($output);
exit;
}
示例5: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
// echo "Sending TemplateSMS to $to <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
echo 0;
}
if ($result->statusCode != 0) {
// echo "error code :" . $result->statusCode . "<br>";
// echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
// echo "Sendind TemplateSMS success!<br/>";
// 获取返回信息
$smsmessage = $result->TemplateSMS;
// echo "dateCreated:".$smsmessage->dateCreated."<br/>";
// echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
//TODO 添加成功处理逻辑
}
}
示例6: sendTemplateSMS
function sendTemplateSMS($to, $datas, $tempId)
{
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$accountSid = 'aaf98f894d328b13014d566d3eca1b83';
$accountToken = '37fbd7a853df4704bd5420f22328fffb';
$appId = '8a48b5514d32a2a8014d56721def1b2b';
$appToken = 'd96986e70dae11e5ac73ac853d9f54f2';
$serverIP = 'sandboxapp.cloopen.com';
$serverPort = '8883';
$softVersion = '2013-12-26';
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//
} else {
echo "Sendind TemplateSMS success!<br/>";
$smsmessage = $result->TemplateSMS;
echo "dateCreated:" . $smsmessage->dateCreated . "<br/>";
echo "smsMessageSid:" . $smsmessage->smsMessageSid . "<br/>";
}
}
示例7: getVerifyCode
function getVerifyCode()
{
$param = json_decode(file_get_contents('php://input'), true);
$phone = $param['phone'];
// $phone = '13269627267';
if (empty($phone)) {
err_ret(-205, 'lack of param', '手机号码为空');
}
$model = new Model('verify_tmp');
//查询对应手机的最后一条记录
$sql_max = "SELECT * from verify_tmp where id = (select max(id) from verify_tmp WHERE phone = '" . $phone . "')";
$result = $model->query($sql_max);
if (count($result) > 0) {
$time = time() - $result[0]['gen_time'];
if ($time < 60) {
//小于1分钟
err_ret(-302, 'too many time get verifycode', '请求验证码过于频繁');
}
}
//判断是否注册过
$model = new Model('user_info');
$where['username'] = $phone;
$result_user_info = $model->where($where)->select();
if (count($result_user_info) > 0) {
err_ret(-205, 'phone number is already registered', '此手机号码已经注册过');
}
//生成验证码和短信模板
$code = rand(1000, 9999);
$data = array($code, '5');
//发送短信验证码
$serverIP = C('RL_ServerIP');
$serverPort = C('RL_ServerPort');
$softVersion = C('RL_SoftVersion');
$accountSid = C('RL_AccountSID');
$accountToken = C('RL_AccountToken');
$appId = C('RL_AppID');
$SmsId = C('RL_SMS_TEMPLATE_ID');
$rest = new \REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
$result = $rest->sendTemplateSMS($phone, $data, $SmsId);
if ($result->statusCode != 0) {
err_ret($result->statusCode, $result->statusMsg);
} else {
//生成验证码,插入数据库
$value['phone'] = $phone;
$value['verifycode'] = $code;
$value['gen_time'] = time();
M("verify_tmp")->add($value);
http_ret(0, 'verify code send success', '验证码发送成功');
}
}
示例8: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
//主帐号,对应开官网发者主账号下的 ACCOUNT SID
$accountSid = 'aaf98f8951ce5b650151d1a4aec20594';
//主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
$accountToken = '50e17e2463254d90aa9c39de44b8924e';
//应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
//在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
$appId = 'aaf98f8951ce5b650151d1a6288305b3';
//请求地址
//沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
//生产环境(用户应用上线使用):app.cloopen.com
$serverIP = 'sandboxapp.cloopen.com';
//请求端口,生产环境和沙盒环境一致
$serverPort = '8883';
//REST版本号,在官网文档REST介绍中获得。
$softVersion = '2013-12-26';
$serverIP = 'sandboxapp.cloopen.com';
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
echo "Sending TemplateSMS to {$to} <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "Sendind TemplateSMS success!<br/>";
// 获取返回信息
$smsmessage = $result->TemplateSMS;
echo "dateCreated:" . $smsmessage->dateCreated . "<br/>";
echo "smsMessageSid:" . $smsmessage->smsMessageSid . "<br/>";
//TODO 添加成功处理逻辑
}
}
示例9: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
$accountSid = '8a48b5514f1702fd014f29ec31de197a';
//主帐号Token
$accountToken = '1fb094b6f956426480f88e8d24f26950';
//应用Id
//测试用
//$appId='aaf98f894f4900a3014f499a536a0099';
//正式运行用,‘志愿者验证’
$appId = '8a48b5514f49079e014f491b9911003e';
//请求地址,格式如下,不需要写https://
//$serverIP='sandboxapp.cloopen.com';
$serverIP = 'app.cloopen.com';
//请求端口
$serverPort = '8883';
//REST版本号
$softVersion = '2013-12-26';
//global $accountSid,$accountToken,$appId,$serverIP,$serverPort,$softVersion;
$rest = new \REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
//echo "Sending TemplateSMS to $to <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
echo "result error!";
// break;
exit;
}
if ($result->statusCode != 0) {
// echo "error code :" . $result->statusCode . "<br>";
// echo "error msg :" . $result->statusMsg . "<br>";
return 0;
} else {
//echo "Sendind TemplateSMS success!<br/>";
// 获取返回信息
//$smsmessage = $result->TemplateSMS;
//echo "dateCreated:".$smsmessage->dateCreated."<br/>";
//echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
return 1;
}
}
示例10: sendTemplateSMS
public function sendTemplateSMS($to, $datas, $tempId)
{
//主帐号,对应开官网发者主账号下的 ACCOUNT SID
$accountSid = ACCOUNTSID;
//主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
$accountToken = ACCOUNTTOKEN;
//应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
//在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
$appId = APPID;
//请求地址
//沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
//生产环境(用户应用上线使用):app.cloopen.com
$serverIP = SERVERIP;
//请求端口,生产环境和沙盒环境一致
$serverPort = SERVERPORT;
//REST版本号,在官网文档REST介绍中获得。
$softVersion = SOFTVERSION;
//开发时注释
$tempId = TEMPID;
// 初始化REST SDK
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == null) {
logger("发送短信失败, mobile=" . $to . ", 短信服务器错误");
return false;
}
if ($result->statusCode != 0) {
logger("发送短信失败, mobile=" . $to . ", errcode=[" . $result->statusCode . "]" . ", errmsg=[" . $result->statusMsg . "]");
return false;
} else {
// 获取返回信息
$smsmessage = $result->TemplateSMS;
// echo "dateCreated:" . $smsmessage->dateCreated . "<br/>";
// echo "smsMessageSid:" . $smsmessage->smsMessageSid . "<br/>";
//TODO 添加成功处理逻辑
logger("发送短信成功, mobile=" . $to . ' dateCreated=' . $smsmessage->dateCreated);
return true;
}
}
示例11: REST
/**
* 发送文字短信
* @param unknown $mobile
* @param unknown $data
* @param unknown $step
*/
function send_text($mobile, $data, $step)
{
global $_CFG;
$rest = new REST($this->config['server_domain'], $this->config['server_port'], $this->config['soft_version']);
$rest->setAccount($this->config['account_sid'], $this->config['account_token']);
$rest->setAppId($this->config['appId']);
if ($this->config['debug'] == 1) {
$rest->setLog(TRUE, ROOT_PATH . '/data/yuntongxun_sms.log');
}
$param = array($data['verifycode'], intval($_CFG['ecsdxt_sms_validtime'] / 60), $_CFG['service_phone']);
// 发送模板短信
$result = $rest->sendTemplateSMS($mobile, $param, $this->config[$step . '_tmpl']);
if ($result == NULL) {
return array('errcode' => 1, 'errmsg' => 'unknown error');
}
if ($result->statusCode != 0) {
return array('errcode' => $result->statusCode, 'errmsg' => $result->statusMsg);
} else {
return true;
}
}
示例12: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
echo "Sending TemplateSMS to {$to} <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
/* echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";*/
return false;
//TODO 添加错误处理逻辑
} else {
return true;
}
}
示例13: SendTemplateSMS
static function SendTemplateSMS($to, $datas, $tempId)
{
//var_dump($to, $datas, $tempId);
// 初始化REST SDK
$rest = new REST(SMS::ServerIP, SMS::ServerPort, SMS::ApiVersion);
//echo 'new rest done' . "\r\n";
$rest->setAccount(SMS::AccountSid, SMS::AccountToken);
//echo 'setAccount done' . "\r\n";
$rest->setAppId(SMS::AppId);
//var_dump($to, $datas, $tempId);
// 发送模板短信
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
throw new SmsException("Failed to send SMS.");
}
if ($result->statusCode != 0) {
throw new SmsException("Got error response from SMS server, code:" . $result->statusCode . ", message:" . $result->statusMsg);
} else {
// 获取返回信息
$smsMessage = $result->TemplateSMS;
return array($result->statusCode, $smsMessage->smsMessageSid, $smsMessage->dateCreated);
}
}
示例14: newOrderNotification
function newOrderNotification($coachid, $uid)
{
if (empty($coachid) || empty($uid)) {
// err_ret(-205,'lack of param','缺少参数');
die;
}
$model = new Model();
$sql = "SELECT id,name,nicker,phone FROM user_info WHERE id IN ({$uid},{$coachid})";
$result = $model->query($sql);
if (count($result) > 0) {
foreach ($result as $value) {
if ($value['id'] == $uid) {
$userNicker = $value['nicker'];
} else {
if ($value['id'] == $coachid) {
$coachName = $value['name'];
$coachPhone = $value['phone'];
}
}
}
// $coachPhone = '18612539907';
$data = array($coachName, $userNicker);
//发送通知
$serverIP = C('RL_ServerIP');
$serverPort = C('RL_ServerPort');
$softVersion = C('RL_SoftVersion');
$accountSid = C('RL_AccountSID');
$accountToken = C('RL_AccountToken');
$appId = C('RL_AppID');
$SmsId = C('RL_SMS_ORDER_ID');
$rest = new \REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
$result_sms = $rest->sendTemplateSMS($coachPhone, $data, $SmsId);
// var_dump($result_sms);
}
}
示例15: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
$ci =& get_instance();
$sms = $ci->config->item('SMSCHANNEL');
$accountSid = $sms['accountSid'];
$accountToken = $sms['accountToken'];
$appId = $sms['appId'];
$serverIP = $sms['serverIP'];
$serverPort = $sms['serverPort'];
$softVersion = $sms['softVersion'];
//global $accountSid,$accountToken,$appId,$serverIP,$serverPort,$softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
//echo "Sending TemplateSMS to $to <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
// if($result == NULL ) {
// echo "result error!";
// break;
// }
// if($result->statusCode!=0) {
// echo "error code :" . $result->statusCode . "<br>";
// echo "error msg :" . $result->statusMsg . "<br>";
// //TODO 添加错误处理逻辑
// }else{
// echo "Sendind TemplateSMS success!<br/>";
// // 获取返回信息
// $smsmessage = $result->TemplateSMS;
// echo "dateCreated:".$smsmessage->dateCreated."<br/>";
// echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
// //TODO 添加成功处理逻辑
// }
return $result;
}