0

We can get external IP from this service using Java, C# or VB.NET. But I want to do that using Adobe AIR. How to make request to that link and get its string?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mudasir Bhutto
  • 468
  • 1
  • 11
  • 24
  • Here is a way to get external ip using java or C# from whatismyip.com http://stackoverflow.com/questions/5543738/difference-between-internal-ip-address-and-external-ip-address – Mudasir Bhutto Apr 07 '11 at 20:25
  • The [original link](http://www.whatismyip.com/automation/n09230945.asp) in this question was removed as it was broken. I will leave it in place in the answer, however. – halfer Aug 05 '18 at 10:24

1 Answers1

0

It will be like this:

private function makeRequest():void
{
    var loader:URLLoader = new URLLoader();

    configureListeners(loader);
    var req:URLRequest=new URLRequest("http://www.whatismyip.com/automation/n09230945.asp");

    try

    {   
        var header:URLRequestHeader=new URLRequestHeader("content-type", "text/plain");

        var header2:URLRequestHeader = new URLRequestHeader("pragma", "no-cache");

        req.requestHeaders.push(header);
        req.requestHeaders.push(header2);

        req.method = URLRequestMethod.POST;
        loader.dataFormat = URLLoaderDataFormat.TEXT;
        loader.load(req);
    }
    catch (error:Error)
    {
        trace("Unable to load requested document.");
    }
}

private function configureListeners(dispatcher:IEventDispatcher):void
{
    dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}

private function completeHandler(event:Event):void
{
    var loader:URLLoader = URLLoader(event.target);
    mx.controls.Alert.show("" + loader.data);
}
Mudasir Bhutto
  • 468
  • 1
  • 11
  • 24