Find Location using IP Address

Hello guys,

This is very interesting post, to find location i used API of hostip.info website. first i need to find IP address of client. based on ip address i gonna fetch location.

For IP address of client please view find the ip address post.

here, i m using  PHP Simple HTML DOM Parser to read content from webpage.

Simple HTML DOM Parser
A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
Require PHP 5+.
Supports invalid HTML.
Find tags on an HTML page with selectors just like jQuery.
Extract contents from HTML in a single line.

to download Parser go to http://simplehtmldom.sourceforge.net/ site.
and include that file on top of php file.

$html = file_get_html('http://api.hostip.info/?ip='.$ip);
foreach($html->find('gml:name') as $element)
$result = @split("",$element);
$fresult = @split("",$result[1]);

This code return the exact city name.!!

hope you like it.!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s