diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2010-08-02 15:54:41 +0200 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2010-08-02 15:54:41 +0200 |
commit | 7e7f15ca0aadcdadcb930ab025be1c7311365078 (patch) | |
tree | a0c454b2f790f87138c5f5ca21af65c0ff43927d | |
parent | ca0095d06dade6118afd8205b99001892b7f1296 (diff) | |
download | rpg-7e7f15ca0aadcdadcb930ab025be1c7311365078.tar.gz rpg-7e7f15ca0aadcdadcb930ab025be1c7311365078.tar.bz2 |
Convenience function in HTTPClient
The new dget() method works accepts URL parameters as associative
array (like the post() method).
-rw-r--r-- | inc/HTTPClient.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index ebe349573..b6feba35a 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -153,6 +153,29 @@ class HTTPClient { } /** + * Simple function to do a GET request with given parameters + * + * Returns the wanted page or false on an error. + * + * This is a convenience wrapper around get(). The given parameters + * will be correctly encoded and added to the given base URL. + * + * @param string $url The URL to fetch + * @param string $data Associative array of parameters + * @param bool $sloppy304 Return body on 304 not modified + * @author Andreas Gohr <andi@splitbrain.org> + */ + function dget($url,$data,$sloppy304=false){ + if(strpos($url,'?')){ + $url .= '&'; + }else{ + $url .= '?'; + } + $url .= $this->_postEncode($data); + return $this->get($url,$sloppy304); + } + + /** * Simple function to do a POST request * * Returns the resulting page or false on an error; |