Created
February 10, 2014 16:17
-
-
Save AngeloR/8918794 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rest_Client { | |
/** | |
* | |
* Perform any get type operation on a url | |
* @param string $url | |
* @return string The resulting data from the get operation | |
*/ | |
public static function get($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
return $data; | |
} | |
/** | |
* | |
* Perform any post type operation on a url | |
* @param string $url | |
* @param array $params A list of post-based params to pass | |
*/ | |
public static function post($url,array $params = array()) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $params); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
return $data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment