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

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值