How to get IP Address using phonegap javascript. I have to send this IP address to php page as a QueryString.
Any Suggestion ?
How to get IP Address using phonegap javascript. I have to send this IP address to php page as a QueryString.
Any Suggestion ?
Here you go:
http://simonmacdonald.blogspot.in/2012/08/so-you-wanna-write-phonegap-200-android.html
Basically, you need to use a phonegap plugin that acts as a javascript wrapper and uses a method from the native android SDK to get you the required IP address.
Do not do any code in you Javascript ant send it to PHP page but in PHP page you can do the following function call to get the Real IP address...
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}