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.
php snoopy类,一个http的php类。和snoopy差不多
最新推荐文章于 2021-03-22 14:18:46 发布