/*=====================短信接收验证============================*/
public function test(){
$to='';要发送到那个手机号
$num='';要发送的数据!
$datas=array($num);
$this->sendTemplateSMS($to,$datas,1);
}
function sendTemplateSMS($to,$datas,$tempId)
{
//注册自己就会有下面的
$accountSid='';
$accountToken='';
$appId='';
$serverIP='app.cloopen.com';
$serverPort='8883';
$softVersion='2013-12-26';
//这个接口需要自己去引用
$rest = new \REST($serverIP,$serverPort,$softVersion);
$rest->setAccount($accountSid,$accountToken);
$rest->setAppId($appId);
// 发送模板短信
echo "Sending TemplateSMS to $to ";
$result = $rest->sendTemplateSMS($to,$datas,$tempId);
if($result == NULL ) {
echo "result error!";
break;
}
if($result->statusCode!=0) {
echo "模板短信发送失败!";
echo "error code :" . $result->statusCode . "";
echo "error msg :" . $result->statusMsg . "";
//下面可以自己添加错误处理逻辑
}else{
echo "模板短信发送成功!";
// 获取返回信息
$smsmessage = $result->TemplateSMS;
echo "dateCreated:".$smsmessage->dateCreated."";
echo "smsMessageSid:".$smsmessage->smsMessageSid."";
}
}
}
更多请进入https://github.com/zslmy/SMS.git下载!查看更多!
------------------------------------------------------------------------------------
https://github.com/zslmy/SMS.git