本文主要和大家分享php實作傳送簡訊實例,主要以程式碼的方式跟大家分享,希望能幫助大家。
1.呼叫alidayu的工具類別包,然後設定參數
public function sendSMS ($mobile, $content,$type,$pcode,$address) { include("TopSdk.php"); date_default_timezone_set('Asia/Shanghai'); $c = new \TopClient(); switch ($type){ case '1': $c->appkey = "*****"; $c->secretKey = "************"; //$req = new AlibabaAliqinFcSmsNumSendRequest; $req = new \AlibabaAliqinFcSmsNumSendRequest(); $req->setSmsType("normal"); $req->setSmsFreeSignName("好运生活"); $req->setSmsParam("{\"village\":\"".$content."\",\"pcode\":\"".$pcode."\",\"address\":\"".$address."\"}"); $req->setRecNum($mobile); $req->setSmsTemplateCode("SMS_127161604"); $resp = $c->execute($req); break; default : $c->appkey = "*****"; $c->secretKey = "**********"; //$req = new AlibabaAliqinFcSmsNumSendRequest; $req = new \AlibabaAliqinFcSmsNumSendRequest(); $req->setSmsType("normal"); $req->setSmsFreeSignName("顺手拿"); $req->setSmsParam("{\"code\":\"".$content."\",\"product\":\"shunshouna\"}"); $req->setRecNum($mobile); $req->setSmsTemplateCode("SMS_33580526"); $resp = $c->execute($req); break; } if($resp->result->success){ return true; } else{ return false; } }
2.呼叫sendSMS方法.並進行處理.
$res = (new Aliyun())->sendSMS($this->_param['mobile'],$this->_param['village'],1,$this->_param['p_code'],$this->_param['address']);
#1.呼叫alidayu的工具類別包,然後配置參數
public function sendSMS ($mobile, $content,$type,$pcode,$address) { include("TopSdk.php"); date_default_timezone_set('Asia/Shanghai'); $c = new \TopClient(); switch ($type){ case '1': $c->appkey = "*****"; $c->secretKey = "************"; //$req = new AlibabaAliqinFcSmsNumSendRequest; $req = new \AlibabaAliqinFcSmsNumSendRequest(); $req->setSmsType("normal"); $req->setSmsFreeSignName("好运生活"); $req->setSmsParam("{\"village\":\"".$content."\",\"pcode\":\"".$pcode."\",\"address\":\"".$address."\"}"); $req->setRecNum($mobile); $req->setSmsTemplateCode("SMS_127161604"); $resp = $c->execute($req); break; default : $c->appkey = "*****"; $c->secretKey = "**********"; //$req = new AlibabaAliqinFcSmsNumSendRequest; $req = new \AlibabaAliqinFcSmsNumSendRequest(); $req->setSmsType("normal"); $req->setSmsFreeSignName("顺手拿"); $req->setSmsParam("{\"code\":\"".$content."\",\"product\":\"shunshouna\"}"); $req->setRecNum($mobile); $req->setSmsTemplateCode("SMS_33580526"); $resp = $c->execute($req); break; } if($resp->result->success){ return true; } else{ return false; } }
2.呼叫sendSMS方法.並進行處理.
$res = (new Aliyun())->sendSMS($this->_param['mobile'],$this->_param['village'],1,$this->_param['p_code'],$this->_param['address']);
相關推薦:
以上是php實作發送簡訊實例的詳細內容。更多資訊請關注PHP中文網其他相關文章!