$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($info == 200){
return json_decode($result);
}
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "http://www.example.com/yourscript.php",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => array(
'field1' => 'some date',
'field2' => 'some other data',
)
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
// result sent by the remote server is in $result
function &web_curl_http($url)
{
$c = curl_init();
curl_setopt( $c , CURLOPT_URL , $url);
curl_setopt( $c , CURLOPT_USERAGENT, "Mozilla/5.0 (Linux Centos 7;) Chrome/74.0.3729.169 Safari/537.36");
curl_setopt( $c , CURLOPT_RETURNTRANSFER, true);
curl_setopt( $c , CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $c , CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $c , CURLOPT_TIMEOUT, 10000); // 10 sec
$data = curl_exec($c);
curl_close($c);
return $data;
}
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "http://www.example.com/yourscript.php",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => array(
'field1' => 'some date',
'field2' => 'some other data',
)
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);