/**
* create request || application/json
* @param $method
* @param $url
* @param $args
* @param $isSentBody
* @param $cert
* @return resource
*/
function createRequest($method, $url, $args, $isSentBody, $cert = false)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if ($method == 'POST')
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($args));
if ($isSentBody) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
//'Authorization : Bearer ' . getAccessToken(),
));
}
if ($cert)
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . $cert);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
try {
return curl_exec($ch);
} catch (Exception $e) {
throw $e;
}
}