今天給大家分享的代碼示例是秒賽短信驗證碼平臺為方便用戶接入網(wǎng)站/app/各種系統(tǒng),提供的PHP短信接口請求的代碼示例,供大家參考。
php短信接口
PHP短信接口代碼具體內(nèi)容如下:
<?php header("Content-Type:text/html;charset=utf-8"); //賬號 $account = "***************"; //密碼 $pswd = "***************"; //修改為您要發(fā)送的手機號 $mobile = "***************"; //發(fā)送地址,請咨詢客服 $url = "***************"; //是否需要狀態(tài)報告,為true即可 $needstatus = "true"; //產(chǎn)品,為空即可 $product = ""; $ch = curl_init(); /* 設置驗證方式 */ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded','charset=utf-8')); /* 設置返回結果為流 */ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); /* 設置超時時間*/ curl_setopt($ch, CURLOPT_TIMEOUT, 10); /* 設置通信方式 */ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 發(fā)送短信 $msg="【秒賽科技】您的驗證碼是:1234"; $data=array('msg'=>$msg,'account'=>$account,'pswd'=>$pswd,'mobile'=> $mobile,'needstatus'=>$needstatus,'product'=>$product); $result = send($ch,$data); echo '<pre>';print_r($result); curl_close($ch); /***************************************************************************************/ //驗證碼 function send($ch,$data){ curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); return curl_exec($ch); } ?>
想查看更多語言(java、c++、js)短信接口示例,點擊:http://lvluoyun.cn/support/show-79.html