티스토리 뷰

프로그래밍/PHP

php 소켓 클래스(설명)

프링글 2008. 6. 22. 13:17

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. 

'프로그래밍 > PHP' 카테고리의 다른 글

php-소켓클래스(Example)  (0) 2008.06.22
php-소켓클래스(데모)  (0) 2008.06.22
2003년 6월식 php 바코드 생성 함수  (0) 2008.06.22
금액(문자) -> 숫자로 변환 함수  (0) 2008.06.22
PHP RSS Reader [RSS 2.0]  (0) 2008.06.17
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크