龙岩易富通网络科技有限公司

龙岩小程序开发,龙岩分销系统

php模拟提交数据

2015.09.10 | 621阅读 | 0条评论 | php

php利用fsockopen模拟提交数据,以下举例是模拟提交龙岩seo留言板 

[php] 

$sock = fsockopen("www.0597seo.com", 80, $errno, $errstr, 30); 

if (!$sock) die("$errstr ($errno)\n"); 

$data = "comment=龙岩seo&author=test&email=test@qq.com&url=http%3A%2F%2F0597seo.com&comment_post_ID=374&comment_parent=0&comment_post_ID=374"; 

fwrite($sock, "POST /wp-comments-post.php HTTP/1.0\r\n"); 

fwrite($sock, "Host: www.0597seo.com\r\n"); 

fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");

fwrite($sock, "Content-length: " . strlen($data) . "\r\n");

fwrite($sock, "Accept: */*\r\n"); 

fwrite($sock, "\r\n"); 

fwrite($sock, "$data\r\n"); 

fwrite($sock, "\r\n"); 

$headers = ""; 

while ($str = trim(fgets($sock, 4096)))     

   $headers .= "$str\n"; echo "\n"; $body = ""; 

   while (!feof($sock))     

      $body .= fgets($sock, 4096); 

   fclose($sock); 

   echo $body; 

[/php]


赞 (

发表评论