Results 1 to 15 of 15
  1. #1
    Join Date
    May 2005
    Location
    Mumbai, India
    Posts
    549

    Get Location By IP

    If I goto http://whois.sc/xxx.xxx.xxx.xxxx I can get the location (approx) of that particular person. I can obviously parse this and store it.
    But is there any way to this directly using PHP ?
    I want to do it the way whois.sc has done it.

    Thanks

  2. #2
    Join Date
    Mar 2004
    Posts
    1,301
    oops never mind, you wanted the location of a given ip... hang on

    http://www.phpclasses.org/browse/package/2099.html

    you need to log in to download the free whois class writtenin php
    Last edited by orbitz; 05-19-2005 at 05:46 AM.

  3. #3
    Join Date
    Mar 2004
    Posts
    1,301
    see if you could get this direct link:

    http://www.phpclasses.org/browse/dow...5-02-06.tar.gz

  4. #4
    Join Date
    May 2005
    Location
    Mumbai, India
    Posts
    549
    Thanks for your reply.
    Direct Link doesnt work - guess its stored in the db - anyway Im already registered with phpclassess - I once looked up this before there but the code had a table full of IP addressess (ranges) that were mapped to a given location - Is it done like that ? No other way ?
    whois.sc is giving the city too.

    Anyway I'll check out this one.
    Thanks.

  5. #5
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Free tutorial + database:

    http://www.phptricks.com/?lesson_id=23&section=2

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  6. #6
    Join Date
    May 2005
    Location
    Mumbai, India
    Posts
    549
    aizny - Thanks but this is a static method - can be run offline too - gave my Ip and returned PK (Pakistan) and not India - an entire country's distance difference.

    orbitz's phpClassess one connects directly to the arinet server (or ripe) and can give almost accurate results - Just to need to make changes for compatibility purposes. But when I gave my IP it returned some wierd location and not the one that whois.sc returned !

    Thanks guys.

  7. #7
    Join Date
    Mar 2004
    Posts
    1,301
    maybe your ip is alien
    I'll keep looking for this kinda of script...will let you know when i found out

  8. #8
    Join Date
    May 2005
    Location
    Mumbai, India
    Posts
    549
    If it were alien then whois.sc wouldnt be giving the correct result. I guess the one at phpclassess was made for an older version of PHP ? Because there seem to be many errors. Fixed though.

  9. #9
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    You can use my friend's service whereisthatip.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  10. #10
    Join Date
    May 2005
    Location
    Mumbai, India
    Posts
    549
    fyrestrtr : Nice and small PHP5 specific SOAP method.
    Excellent for getting the country only - but whois.sc is returning one big list of data which I would like to have.

    Thanks anyway for that SOAP link - very good one for future use.

  11. #11
    Join Date
    Sep 2004
    Location
    Sussex, England
    Posts
    193
    Originally posted by fyrestrtr
    You can use my friend's service whereisthatip.
    I just tried that with my IP and it couldnt get any information.

  12. #12
    Join Date
    May 2005
    Location
    Mumbai, India
    Posts
    549
    b0wser : How on earth did you get to use the SOAP API ? Or did you just use the site service ?
    Using the site service it returned India which is correct for me.

    Im unable to get to use the SOAP method.
    At http://www.e-riding.com/whereisthatip its mentioned Registration is not required, but here http://www.e-riding.com/whereisthatip/soap-howto its mentioned When you register you will be given a unique user ID code, and this ID code must be supplied in each request you make.

    Is there any global common userid ?

    Thanks

  13. #13
    try www.webhosting.info
    here you can find many many information about IPs.
    how you should understand them, where your script can get data from(I mean which DB) and etc
    check that out

  14. #14
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Originally posted by anjanesh
    aizny - Thanks but this is a static method - can be run offline too - gave my Ip and returned PK (Pakistan) and not India - an entire country's distance difference.

    orbitz's phpClassess one connects directly to the arinet server (or ripe) and can give almost accurate results - Just to need to make changes for compatibility purposes. But when I gave my IP it returned some wierd location and not the one that whois.sc returned !

    Thanks guys.
    as far as I know and tested, it works perfectly for me..

    sometimes it does not dedeict it right if im using it on localhost thou..

    maybe,

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  15. #15
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    anjanesh:

    Here is an example that doesn't require PHP5. You will need to download and install the nuSoap php library. Its free, and can be installed on a shared hosting environment. Either that, or you can use any number of the SOAP classes available.

    Here is an example using nusoap :

    PHP Code:
      <?php

          
    require_once 'nusoap.php'

          
    //Create a new client from the wsdl file
          
    $soap = new soapclient('http://xml.whereisthatip.com/ip-location-service.wsdl','wsdl');
          
          
    //Generate a proxy for this wsdl
          
    $client $soap->getProxy();
          
          
    $uid "your-user-id";
          
    $ip   "some.ip.address";

          
    $result $client->getLocationRequest($uid,$ip);
          if (
    $client->getError())
          {
              echo 
    'There was an error with the request<br />';
              echo 
    $client->getError();
          } else {
              echo 
    'You are from '.$result;
          }
      
    ?>
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •