/*=====================短信接收驗(yàn)證============================*/
public function test(){
$to='';要發(fā)送到那個(gè)手機(jī)號(hào)
$num='';要發(fā)送的數(shù)據(jù)!
$datas=array($num);
$this->sendTemplateSMS($to,$datas,1);
}
function sendTemplateSMS($to,$datas,$tempId)
{
//注冊(cè)自己就會(huì)有下面的
$accountSid='';
$accountToken='';
$appId='';
$serverIP='app.cloopen.com';
$serverPort='8883';
$softVersion='2013-12-26';
//這個(gè)接口需要自己去引用
$rest = new \REST($serverIP,$serverPort,$softVersion);
$rest->setAccount($accountSid,$accountToken);
$rest->setAppId($appId);
// 發(fā)送模板短信
echo "Sending TemplateSMS to $to ";
$result = $rest->sendTemplateSMS($to,$datas,$tempId);
if($result == NULL ) {
echo "result error!";
break;
}
if($result->statusCode!=0) {
echo "模板短信發(fā)送失敗!";
echo "error code :" . $result->statusCode . "";
echo "error msg :" . $result->statusMsg . "";
//下面可以自己添加錯(cuò)誤處理邏輯
}else{
echo "模板短信發(fā)送成功!";
// 獲取返回信息
$smsmessage = $result->TemplateSMS;
echo "dateCreated:".$smsmessage->dateCreated."";
echo "smsMessageSid:".$smsmessage->smsMessageSid."";
}
}
}
更多請(qǐng)進(jìn)入https://github.com/zslmy/SMS.git下載!查看更多豪椿!
------------------------------------------------------------------------------------
https://github.com/zslmy/SMS.git