PHP Curl Format
try {
$url = "http://checkip.amazonaws.com";
$ch = curl_init();
$headers = array(
'Accept: application/json',
'Content-Type: application/json',
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$res = json_decode($result,true);
$ipaddress = $result;
}
catch(Exception $e) {
$ipaddress = 'Exception Message: ' .$e->getMessage();
}
Comments
Post a Comment