Skip to content

Instantly share code, notes, and snippets.

@getmanzooronline
Created February 18, 2015 12:00
Show Gist options
  • Save getmanzooronline/f4b795b246cb8386f128 to your computer and use it in GitHub Desktop.
Save getmanzooronline/f4b795b246cb8386f128 to your computer and use it in GitHub Desktop.
/**
* CURL funtion to post some data to an URL
* @param string $url
* @param array $post
* @return string
*/
private function curl($url,$post="")
{
$curl = curl_init();
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,5);
if($post!="")
{
curl_setopt($curl,CURLOPT_POST,5);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
}
curl_setopt($curl, CURLOPT_USERAGENT, $userAgent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$contents = curl_exec($curl);
curl_close($curl);
return $contents;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment