php通過http調用驗證碼短信接口源碼
來源:程序員人生 發布時間:2015-03-14 09:24:09 閱讀次數:3464次
通過驗證碼短信http調用接口,您可以很快速的在網站或app中集成手機號驗證功能,該源碼只是核心代碼,具體可以根據您的實際需求進行擴大。
<?php
function Post($curlPost,$url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
$return_str = curl_exec($curl);
curl_close($curl);
return $return_str;
}
$target = "http://106.ihuyi.com/webservice/sms.php?method=Submit";
//替換成自己的測試賬號,參數順序和wenservice對應
$post_data = "account=用戶名&password=密碼&mobile=手機號碼&content=".rawurlencode("您的驗證碼是:4852。請不要把驗證碼泄漏給其他人。");
//$binarydata = pack("A", $post_data);
echo $gets = Post($post_data, $target);
//請自己解析$gets字符串并實現自己的邏輯
?>
自助申請帳戶地址:http://www.ihuyi.com/product.php
完全接口文件地址:http://www.ihuyi.com/upload/file/cu-fa-jie-kou.rar
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈