_cookie}rn"); fputs($fp, "/> _cookie}rn"); fputs($fp, ">

首頁 >後端開發 >php教程 >php-PHP转Java该怎么实现,请大神帮忙

php-PHP转Java该怎么实现,请大神帮忙

WBOY
WBOY原創
2016-06-02 11:33:25828瀏覽

php

<code>protected function _postWithCookie($uri, $data){    $fp = fsockopen('f.10086.cn', 80);    fputs($fp, "POST $uri HTTP/1.1\r\n");    fputs($fp, "Host: f.10086.cn\r\n");    fputs($fp, "Cookie: {$this->_cookie}\r\n");    fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");    fputs($fp, "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1\r\n");    fputs($fp, "Content-Length: ".strlen($data)."\r\n");    fputs($fp, "Connection: close\r\n\r\n");    fputs($fp, $data);    $result = '';    while (!feof($fp))    {        $result .= fgets($fp);    }    fclose($fp);    return $result;}</code>

这段代码用Java怎么实现

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn