php 模拟表单提交

<?php
$username = "******";
$password = "*****";
$tel = "*****";
$post_data = "username=".$username."&password=".$password."&content=".$tel;

$length = strlen($post_data);
$url = "http://gh.goto3gnow.com/admin_sms/api/sms/create.php";
$host = "gh.goto3gnow.com";
$port = "80";
$request.="POST ".$url." HTTP/1.1\r\n";
$request.="Host: ".$host."\r\n";
$request.="Content-type: application/x-www-form-urlencoded\r\n";
$request.="Accept: */*\r\n";
$request.="Accept-Charset: utf-8, gb2312\r\n";
$request.="Accept-Language: zh-cn, en;q=0.7\r\n";
$request.="Content-length: ".$length." \r\n";
$request.="Connection: close\r\n";
$request.="\r\n";
$request.=$post_data."\r\n";
$request.="\r\n";
//print_r($request);
$fp = fsockopen($host,$port);
fputs($fp, $request);
while(!feof($fp)) {
 $result .= fgets($fp, 128);
}
fclose($fp);
//print_r($post_data);
//print_r($request);
$body= stristr($result,"\r\n\r\n");//???\r\n
$body=substr($body,4,strlen($body));//???header
print_r($body);
?>

 http://blog.sina.com.cn/s/blog_6021b66d0100u75d.html

posted @ 2016-10-24 14:46  fleam  阅读(2048)  评论(0编辑  收藏  举报