一、下載源碼
PHP DEMO下載二、使用幫助
2.1 DEMO結(jié)構(gòu)
說(shuō)明:
1、phpdemo_func.php:此文件中封裝了常用的函數(shù); 2、phpdemo.php:此文件中演示如何調(diào)用江蘇美圣短信接口;
2.2 初始參數(shù)
$svr_param['username'] = '********'; // 賬號(hào) $svr_param['password'] = '********'; // 密碼 $svr_param['veryCode'] = '********'; // 通訊認(rèn)證Key
2.3 接口使用
2.3.1 普通短信
$param = $svr_param; $param['mobile'] = '138xxxxxxxx'; $param['content']= iconv("gbk","utf-8","您好!您本次驗(yàn)證碼為6688,請(qǐng)勿告知他人"); $param['msgtype']= '1'; // 1-普通短信,2-模板短信 $param['code'] = 'utf-8'; // utf-8,gbk $soap = new SoapClient($svr_url); $stru_para = new sendMsg($param); $result = $soap->sendMsg($stru_para); echo_xmlarr($result->return); // 返回值輸出
普通短信接口的調(diào)用只需開(kāi)發(fā)者傳遞接收者手機(jī)號(hào)和短信內(nèi)容兩個(gè)參數(shù)。普通短信需要人工審核,因此短信有可能會(huì)有一定的延遲。如果發(fā)送驗(yàn)證碼類(lèi)等其他需要即時(shí)接收的短信請(qǐng)使用模板短信,請(qǐng)看下一節(jié)。
2.3.2 模板短信
$param = $svr_param; $param['mobile'] = '138xxxxxxxx'; $param['content']= iconv("gbk","utf-8","@1@=姓名,@2@=".rand(100000,999999)); $param['msgtype']= '2'; // 1-普通短信,2-模板短信 $param['tempid'] = 'JSM40004-0000'; // 模板編號(hào) $param['code'] = 'utf-8'; // utf-8,gbk $soap = new SoapClient($svr_url); $stru_para = new sendMsg($param); $result = $soap->sendMsg($stru_para); echo_xmlarr($result->return); // 返回值輸出
模板短信免審核,即時(shí)到達(dá)
2.3.3 獲取狀態(tài)報(bào)告
$soap = new SoapClient($svr_url); $param = $svr_param; $stru_para = new queryReport($param); $result = $soap->queryReport($stru_para); echo_xmlarr($result->return); // 返回值輸出
只允許查詢(xún)當(dāng)天的,已獲取的狀態(tài)報(bào)告后續(xù)不會(huì)再獲取
2.3.4 獲取獲取上行短信
$soap = new SoapClient($svr_url); $param = $svr_param; $stru_para = new queryMo($param); $result = $soap->queryMo($stru_para); echo_xmlarr($result->return); // 返回值輸出
只允許查詢(xún)當(dāng)天的,已獲取的上行短信后續(xù)不會(huì)再獲取
2.3.5 獲取余額
$soap = new SoapClient($svr_url); $param = $svr_param; $stru_para = new getAmount($param); $result = $soap->getAmount($stru_para); echo_xmlarr($result->return); // 返回值輸出