折雨的天空

新浪微薄腾讯微薄

最新碎语:最近霉到了住。哎。。。

您的位置:折雨的天空 >php开发> 一个http的php类。和snoopy差不多

一个http的php类。和snoopy差不多

可以用于采集的哦。好久试一下。手册比较简单
复制过来

Only methods that are intended to be called from outside the script are described. For details of internal methods, Use The Source :)

HttpClient($host, $port = 80)
Constructor. Takes the web server host (for example, 'scripts.incutio.com') and an optional port.
bool get($path, $data = false)
Executes a GET request for the specified path. If $data is specified, appends it to a query string as part of the get request. $data can be an array of key value pairs, in which case a matching query string will be constructed. Returns true on success and false on failure. If false, an error message describing the problem encountered can be accessed using the getError() method.
bool post($path, $data)
Executes a POST request to the specified path, sending the information from specified in $data. $data can be an array of key value pairs, in which case a matching post request will be constructed. Returns true on success and false on failure. If false, an error message describing the problem encountered can be accessed using the getError() method.
string getContent()
Returns the content of the HTTP response. This is usually an HTML document.
string getStatus()
Returns the status code of the response - 200 means OK, 404 means file not found, etc.
array getHeaders()
Returns the HTTP headers returned by the server as an associative array.
string getHeader($header)
Returns the specified response header, or false if it does not exist.
string getError()
Returns a string describing the most recent error.
string getRequestURL()
Returns the full URL that has been requested.
array getCookies()
Returns an array of cookies set by the server.
string quickGet($url)
Static method designed for running simple GET requests. Usage is:
$pageContent = HttpClient::quickGet($url);
Returns the empty string on failure.
string quickPost($url, $data)
Static method designed for running simple POST requests. Usage is:
$pageContent = HttpClient::quickPost($url, $data);
Returns the empty string on failure. See also post().
void setUserAgent($string)
Sets the user agent string to be used in the request. Default is "Incutio HttpClient v$version".
void setAuthorization($username, $password)
Sets the HTTP authorization username and password to be used in requests. Don't forget to unset this in subsequent requests to different servers.
void setCookies($array)
Sets the cookies to be sent in the request. Takes a 2D array of name value pairs.
void setUseGzip($boolean)
Specify if the client should request gzip encoded content from the server (saves bandwidth but can increase processor time). Default behaviour is TRUE.
void setPersistCookies($boolean)
Specify if the client should persist cookies between requests. Default behaviour is TRUE.
void setPersistReferers($boolean)
Specify if the client should use the URL of the previous request as the referral of a subsequent request. Default behaviour is TRUE.
void setHandleRedirects($boolean)
Specify if the client should automatically follow redirected requests. Default behaviour is TRUE.
void setMaxRedirects($int)
Set the maximum number of redirects allowed before the client quits (mainly to prevent infinite loops) Default is 5.
void setHeadersOnly($boolean)
If TRUE, the client only retrieves the headers from a page. This could be useful for implementing things like link checkers. Defaults to FALSE.
void setDebug($boolean)
Should the client run in debug mode? Default behaviour is FALSE.
void debug($message, $object = false)
This method is not intended to be called from outside the class; it is the method the class calls whenever there is debugging information available. $msg is a debugging message and $object is an optional object to be displayed (usually an array). Default behaviour is to display the message and the object in a red bordered div. If you wish debugging information to be handled in a different way you can do so by creating a new class that extends HttpClient and over-riding the debug() method in that class.

http://scripts.incutio.com/httpclient/manual.php

------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------

转载请注明本文标题和链接:《一个http的php类。和snoopy差不多

奖励一下

取消

分享不易,烦请有多多打赏,如您也困难,点击右边关闭即可!

扫码支持
扫码打赏,5元,10元,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

-秒后自动关闭,如已打赏,或者不愿打赏,请点击右上角关闭图标。

发表评论

路人甲 表情
看不清楚?点图切换