From 7e7f15ca0aadcdadcb930ab025be1c7311365078 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 2 Aug 2010 15:54:41 +0200 Subject: Convenience function in HTTPClient The new dget() method works accepts URL parameters as associative array (like the post() method). --- inc/HTTPClient.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index ebe349573..b6feba35a 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -152,6 +152,29 @@ class HTTPClient { return $this->resp_body; } + /** + * 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 + */ + 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 * -- cgit v1.2.3