jsonip.appspot.com Over Quota

It appears that jsonip.appspot.com is over quota. What alternatives do you have?

  • http://jsonip.com/
  • http://freegeoip.appspot.com/ – This one is currently over quota as well

Have another? Post it below!

Or, Write Your Own with PHP:

<?php

$ip = !empty($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'';
$json = array();
$json['ip'] = $ip;

if(!empty($_GET['callback'])){
	//remove non standard characters if callback is set
	$callback = preg_replace('#[^a-zA-Z0-9\-\_]#','',$_GET['callback']);
}

if(!empty($callback)){
	//if callback still exists after cleaning up non standard characters
	//then call that function with the IP data
	echo $callback.'('.json_encode($json).');';	
}else{
	//else echo the IP data
	echo json_encode($json);
}

?>

Note: It is important to put this on a FAST server otherwise your webpage might hang when loading, especially if you are using the a doc-ready syntax for javascript.

Have improvements? Post them below.

Related Posts:

  • No Related Posts
This entry was posted in Web Development. Bookmark the permalink.

2 Responses to jsonip.appspot.com Over Quota

  1. adam says:

    Remember to double-check that $_SERVER['REMOTE_ADDR'] honours X-forwarded-for headers or you’ll end up logging the wrong ip address for users behind proxies (including your own if you are using load-balancing reverse proxies)

  2. W says:

    Very true. Do you have an example of the best way to check the real remote address in php?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>