php curl
// The ultimate function for all php curl requests all in one
function curl( $api_url,$request = 'get' , $params = array() , $mode = false , $timeout='')
{
$request = strtolower($request);
$ch = curl_init($api_url);
if($request == 'post')
{
curl_setopt ($ch, CURLOPT_POST, TRUE);
curl_setopt ($ch, CURLOPT_POSTFIELDS, http_build_query($params));
}
if( $timeout != '' )
{
curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);
}
if($request == 'put')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
if($request == 'delete')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
}
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if($mode)
$response = json_decode($response , $mode);
else
$response = json_decode($response);
return $response;
}