PHP示例一
<%?php header("Content-Type: text/html; charset=utf-8"); function Post($data, $target) { $url_info = parse_url($target); $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n"; $httpheader .= "Host:" . $url_info['host'] . "\r\n"; $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n"; $httpheader .= "Content-Length:" . strlen($data) . "\r\n"; $httpheader .= "Connection:close\r\n\r\n"; //$httpheader .= "Connection:Keep-Alive\r\n\r\n"; $httpheader .= $data; $fd = fsockopen($url_info['host'], 80); fwrite($fd, $httpheader); $gets = ""; while(!feof($fd)) { $gets .= fread($fd, 128); } fclose($fd); return $gets; } $target = "http://sms.106jiekou.com/utf8/sms.aspx"; //替換成自己的賬號和接口密碼 $post_data = "account=帳號&password=接口密碼&mobile=手機號碼&content=".rawurlencode("您的訂單編碼:4557。如需幫助請聯系客服。"); echo $gets = Post($post_data, $target); //請自己解析$gets字符串并實現自己的邏輯 //100 表示成功,其它的參考文檔 ?>
PHP示例二
<%?php header("Content-Type: text/html; charset=utf-8"); 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://sms.106jiekou.com/utf8/sms.aspx"; //替換成自己的賬號和接口密碼 $post_data = "account=帳號&password=接口密碼&mobile=手機號碼&content=".rawurlencode("您的訂單編碼:4557。如需幫助請聯系客服。"); echo $gets = Post($post_data, $target); //請自己解析$gets字符串并實現自己的邏輯 //100 表示成功,其它的參考文檔 ?>