5 Replies Latest reply on May 2, 2009 10:04 PM by jbenson@oper8

    fetching the physical address of a computer

    rahimhaji Level 1
      Dear Friends,

      I want to fetch the physical address of the computer which is using my application. is there any command or option to do so. pls help me i need to use it in my project.

      Thanks and Regards,

      Syed Abdul Rahim
        • 1. fetching the physical address of a computer
          jbenson@oper8 Level 2
          Edited to include Physical (Geo) address stuff.

          Do you mean IP Address or actual physical (ie postal) address?

          For physical address your only solution is to use a service like hostip.info or a similar service. In my experience geo location to IP is relatively accurate for most providers. The method for obtaining that would be similar to the IP address stuff below. (In my experience the best resolution you can count on is country, and you'll get that about 70% of the time. Frankly for the other 30%, depending on the service, the results can be wildly inaccurate.)

          If you mean IP address then I can only think of one way to handle this because unless I'm wrong the flash API doesn't provide a method and you'll need to fetch this from a website or service.

          I put a really basic example below on fetching data from a website (which you probably know, but it's there in case anyone else is wanting it.)

          It would be nice if the Network Monitor built into air could provide IP info but I do not believe it does. (help on that here: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7fcc. html )



          Fetch IP address (using URLLoader) example:

          Consider if you used PHP on a website: Create a File Called ip.php, it's contents should be:
          <?PHP echo $_SERVER['REMOTE_ADDR']; ?>

          In your HTML/AJAX AIR application (Actionscript will be kinda similar):

          function fetchIPAddress(){
          var locURLRequest = new air.URLRequest(),
          locURLLoader = new air.URLLoader();

          locURLRequest.url = ' http://www.example.com/ip.php';
          locURLRequest.method = air.URLRequestMethod.GET;

          locURLLoader.dataFormat = air.URLLoaderDataFormat.TEXT;
          locURLLoader.addEventListener(air.Event.COMPLETE, ipFetched);
          locURLLoader.addEventListener(air.IOErrorEvent.IO_ERROR, fetchError);
          locURLLoader.load(locURLRequest);
          }

          /* URLLoader.load event return */
          function ipFetched ( event ) {
          loader = event.target;

          alert('My Returned data is ' + loader.data);
          }

          /* URLLoader.load event error */
          function fetchError ( e ) {
          air.trace('Event Error, ' + e.text);
          }

          /* call the function */
          fetchIPAddress();
          • 2. Re: fetching the physical address of a computer
            rahimhaji Level 1
            Dear Mr.jbenson,
            Thks for your reply. I need to find the physical address of an indvidual system. that number should be unique for all the sytem. With that number i can find how many times they are using my applicaiton.

            pls help any of my friends....

            Thanks and Regards,

            Syed Abdul Rahim
            • 3. Re: fetching the physical address of a computer
              jbenson@oper8 Level 2
              Ah

              I do this by having the app generate a key first time at startup, store it in the SQLite database and sending that key back to my webservice. (We make the key by using a random 128 character string in js, technically that could duplicate but it's within an acceptable margin of error to me.).

              That way I'm not sending any private information in any form back to the server and I always know how many apps are out there and can revoke an individual's key at any time.

              Let me know if you'd like some code.
              • 4. Re: fetching the physical address of a computer
                Buch90

                Hi,

                 

                Are you using html and java? If so I'd really like to see the code for that or just at least a little y´tutorial on how to use the sqlite database.

                 

                Regards

                • 5. Re: fetching the physical address of a computer
                  jbenson@oper8 Level 2

                  I can't say how little this is (nor is it really a tutorial) but I uploaded some code and a post just now about how I access SQLite databases as well as generation of a random key in javascript.   (see code within my ns.airDB.js file for exact code needed for synchronous access of the database.  I'll be uploading my asynch version in a few days likely).

                   

                  Unsure if something like this is what you're looking for and frankly it's a bit more involved than some of the help over at http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118676a5497-7fb4. html.

                   

                  But regardless, here ya go: http://vfoo.wordpress.com/2009/05/02/adobe-air-15-and-sqlite-example/