Skip to content

Commit

Permalink
Convenience function in HTTPClient
Browse files Browse the repository at this point in the history
The new dget() method works accepts URL parameters as associative
array (like the post() method).
  • Loading branch information
splitbrain committed Aug 2, 2010
1 parent ca0095d commit 7e7f15c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions inc/HTTPClient.php
Expand Up @@ -152,6 +152,29 @@ function get($url,$sloppy304=false){
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 <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
*
Expand Down

0 comments on commit 7e7f15c

Please sign in to comment.