dimoss
Well-Known Member
Hi all,
Searching older posts I found the following thread which seems to be an approach to get the country using an API having the user IP.
https://fabrikar.com/forums/index.php?threads/get-country.49532/#post-259049
I applied it creating a form using a calc element with the following code using the free API from https://ip-api.com/
Now the funny part comes. As long as i remove the comment from 'var_dump($hostinfo)' the script gives exits with the correct info and the correct country which in my case is Greece. If I comment 'var_dump($hostinfo)' the script records a wrong country which is always Finland regardless if I use or not use a VPN! Same it happens for others which i gave the same form URL to try.
In all cases the $api_url is correct.
I have no clue why this is happening.
Searching older posts I found the following thread which seems to be an approach to get the country using an API having the user IP.
https://fabrikar.com/forums/index.php?threads/get-country.49532/#post-259049
I applied it creating a form using a calc element with the following code using the free API from https://ip-api.com/
PHP:
$ip = '{fab_ratings___ip}';
$api_url = 'http://ip-api.com/json/'.urlencode($ip);
//var_dump($api_url);exit;
$hostinfo = file_get_contents($api_url);
//var_dump($hostinfo);exit;
$hostinfo = json_decode($hostinfo);
return $hostinfo->country;
Now the funny part comes. As long as i remove the comment from 'var_dump($hostinfo)' the script gives exits with the correct info and the correct country which in my case is Greece. If I comment 'var_dump($hostinfo)' the script records a wrong country which is always Finland regardless if I use or not use a VPN! Same it happens for others which i gave the same form URL to try.
In all cases the $api_url is correct.
I have no clue why this is happening.