<?php
// simple post method
// version 1.0 by andrus (andrus@vnet.ee)
// disclaimer:
// everyone can change or use this code however and wherever they want ;)
// nb! for posting to microsoft platform webservers you may need to change newlines "\n" to "\r\n"
// microsoft always breaks standards ...
// send out "browser" headers
function send_headers ($fp) {
fputs ($fp, "accept: */*\n");
fputs ($fp, "accept-language: en\n");
fputs ($fp, "connection: keep-alive\n");
fputs ($fp, "user-agent: mozilla/4.0 (compatible; msie 5.5; windows 98)\n");
}
// post data and return reply
function post_data ($host, $url, $data) {
$fp = @fsockopen ($host, 80, $errno, $errstr, 120);
$ret = "";
if (strncasecmp ($url, "http://", 7) == 0) $url = substr ($url, 7);
$p = strpos ($url, '/');
if (empty ($p)) {
$req = "/";
} else {
$req = substr ($url, $p);
}
if ($fp) {
fputs ($fp, "post $req http/1.0\n");
send_headers ($fp);
fputs ($fp, "content-type: application/x-www-form-urlencoded\n");
$out = "";
while (list ($k, $v) = each ($data)) {
if(strlen($out) != 0) $out .= "&&qu
| 对此文章发表了评论 |
