/** * Post * Execute an HTTP POST request, posting the past parameters * @param string $url url to request * @param array $data past data to post to $url * @param array $headers additional headers to send in the request * @param bool $headers_only flag to return only the headers * @param array $curl_options additional curl options to instantiate curl with * @return string result */ public static function post($url, array $data = array(), array $headers = array(), $headers_only = FALSE, array $curl_options = array()) { $url = !strpos('://', $url) ? 'http://' . $_SERVER['HTTP_HOST'] . $url : $url; #return $url; $ch = Helper_Curl::factory($curl_options); $ch->set_opt(CURLOPT_URL, $url)->set_opt(CURLOPT_NOBODY, $headers_only)->set_opt(CURLOPT_RETURNTRANSFER, TRUE)->set_opt(CURLOPT_POST, TRUE); $ch->set_opt(CURLOPT_POSTFIELDS, http_build_query($data)); //Set any additional headers if (!empty($headers)) { $ch->set_opt(CURLOPT_HTTPHEADER, $headers); } return json_decode($ch->execute(), true); }
function request($url) { Helper_Curl::get($url); return Helper_Curl::get($url); }