php的http数据传输get/post...
一般有:file_get_contents,curl,fsockopen....
下面介绍fsockopen:
//构造要post的字符串 $argv = $_POST; $data = http_build_query($argv); $length = strlen($data); //创建socket连接 $fp = fsockopen("order.com",80,$errno,$errstr,10) or exit($errstr."--->".$errno); //构造post请求的头 $header = "POST /pay/sub HTTP/1.1 "; $header .= "Host:order.com "; $header .= "Content-Type: application/x-www-form-urlencoded "; $header .= "Content-Length: ".$length." "; $header .= "Connection: Close "; //添加post的字符串 $header .= $data." "; //发送post的数据 fputs($fp,$header); $inheader = 1; while (!feof($fp)) { $line = fgets($fp,10240); //去除请求包的头只显示页面的返回数据 if ($inheader && ($line == " " || $line == " ")) { $inheader = 0; } if ($inheader == 0) { //echo $line; } } echo $line; exit;
还有他人封装好的:Requests类。