×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    24

    Question Get Phone IP address

    How do I get phone IP address in S40 WebApps? or if it's not possible, now do I get Nokia proxy IP address?

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Get Phone IP address

    Hi,

    There is no official way to get device IP address. If you want to get IP address of the proxy you can do it with following PHP script.

    However the real question is, is there any use cases where IP address could be used?

    Code:
    <?php
     $ip = getenv("REMOTE_ADDR") ; 
     echo "IP " . $ip; 
     ?>


    Br,
    Ilkka
    Last edited by isalento; 2011-11-09 at 08:27.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Location
    Port Elizabeth, South Africa
    Posts
    37

    Re: Get Phone IP address

    Hi,

    Quote Originally Posted by ariefbayu View Post
    How do I get phone IP address in S40 WebApps? or if it's not possible, now do I get Nokia proxy IP address?
    There is the HTTP_X_Forwarded_For header added by the proxy. This is a pretty official approach with respect to how proxy servers work and the Nokia Web App proxy server is no different. I've set up a very simple phpinfo() page at http://hapnic.com/info.php that will list the variables passed to a remote server. If you create a simple web app to get this then it should display the device's IP address.

    A remote script, more advanced than my really simple phpinfo(32), would be able to read the HTTP_X_Forwarded_For header variable and return it back to the client for display. And, if for some unknown reason this header disappears, then you can return the remote_addr header instead. But I am sure it won't disappear.

    I've tested the Ajax retrieval of my info page with the following javascript where "info" is the ID of a div in my web app:
    Code:
    function getInfo() {
    	var info = document.getElementById('info');
    	var xmlhttp;
    	xmlhttp = new XMLHttpRequest();
    	xmlhttp.open("GET", "http://hapnic.com/info.php", false);
    	xmlhttp.send();
    
    	if (xmlhttp.status == 200) {
    		info.innerHTML = xmlhttp.responseText;
    	} else {
    		verse.innerHTML = 'Communication error occurred';
    	}
    }
    Regards,
    Stephen
    Last edited by sperelson; 2011-11-10 at 21:24.

  4. #4
    Registered User
    Join Date
    May 2011
    Posts
    24

    Re: Get Phone IP address

    Quote Originally Posted by isalento View Post
    However the real question is, is there any use cases where IP address could be used?
    For clarification:
    I need to get the IP (either proxy or device IP) from within my s40 web app. I need this IP to submit request to external API.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Re: Get Phone IP address

    I have the same question and one more : can i get client's simcard's number ?.

  6. #6
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Get Phone IP address

    Quote Originally Posted by ariefbayu View Post
    For clarification:
    I need to get the IP (either proxy or device IP) from within my s40 web app. I need this IP to submit request to external API.
    OK newer tough that possibility.

    I summed this thread into a wiki page. It pretty much follows the principles that Stephen proposed in his post.
    http://www.developer.nokia.com/Commu...ies_40_Web_App
    Stephen, feel free to add/fix the article if you spot any issues.

    Br,
    Ilkka

  7. #7
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Get Phone IP address

    Quote Originally Posted by only_once View Post
    I have the same question and one more : can i get client's simcard's number ?.

    Hello and welcome to forum!

    I afraid that you can't. If you want to have some kind of unique ID, best bet is to generate random string and store it to Web App preferences.

    Br,
    Ilkka

  8. #8
    Registered User
    Join Date
    Jul 2012
    Posts
    5

    Re: Get Phone IP address

    This is web apps, you can get client number but i you wanna get IP address client you can't again because your client using a proxy from nokia.

    This is script for get IP client with PHP :

    <?php
    $ip = getenv("REMOTE_ADDR") ;
    echo "IP " . $ip;
    ?>

Similar Threads

  1. Get the phone ip address
    By nirtanami in forum Symbian
    Replies: 2
    Last Post: 2009-01-07, 07:21
  2. IP phone address
    By matrix241 in forum General Development Questions
    Replies: 2
    Last Post: 2008-03-21, 18:43
  3. Getting phone Ip address
    By rajagopal.naidu in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-01-08, 08:58
  4. How do I determine the IP address of my phone?
    By tote in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2006-09-15, 09:49
  5. phone MSISDN an IP address
    By frederic.visticot in forum Mobile Java General
    Replies: 2
    Last Post: 2004-12-03, 15:30

Posting Permissions

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