Jump to content

Recommended Posts

Hey guys,

 

iplocatethis.com is a netgeo tool that maps an IP address to it's (general) location. The way it's done is the page returns a longitude and latitude for a submitted IP address. What i wanted to do was to get the data the site returns and store it as a PHP variable.

 

http://www.iplocatethis.com/location.php?ip=203.22.30.33

 

If you then look at the page source you can see the XML data.

 

What i wanted to know was, how can i get the XML data and store it (in the quickest and most effective way)? Any functions that can help me?

 

Cheers,

/Rhys

Link to comment
https://forums.phpfreaks.com/topic/70971-return-data-from-iplocatethiscom/
Share on other sites

probably pasre the page, using

 

http://uk2.php.net/manual/en/function.file-get-contents.php

http://uk2.php.net/manual/en/ref.xml.php

then store in a database maybe...

 

the most effective way really depends what you want to do with it,

if you wanted an easy solution my best sergestion as fare as getting the data would be use CURL to get the page its self as it in to a veriable given all you want to do is receave the data as is it isnt all that hard find some details on how to do this here

 

http://au2.php.net/curl

 

once you have it simple use preg match more information on this here

http://au.php.net/preg_match

but you could probably get away with somthing as simple as

$lat = preg_match("/lat=\"(.*)\"", $Body, $matches);

 

would give you the veriable.... what do you think?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.