Im having dificult having users location by Curl.
i have this code :
$ip ='123.125.114.144';
$result ='Unkown' ;
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.iptolatlng.com/?ip='.$ip);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$ip_data = curl_exec($ch);
curl_close($ch);
if($ip_data && $ip_data->countryFullName != null) //---the error is in this line
{
$result = $ip_data->countryFullName;
}
echo $result;
However im getting this error:
Notice: Trying to get property of non-object in /mywebsite/index.php on line 29 Unknown
for testing purpose this is their link with random ip http://www.iptolatlng.com/?ip=123.125.114.144
any help will be much apreciated on whats going wrong.