Sunday, 25 March 2012

Universal way to identify your external IP and more

There are many such kind of resources in Internet but this is the best. It allows the numerous structured data and it has nice name. Meet http://ifconfig.me/.
Command line interface
Using curl
curl ifconfig.me
or wget
wget -qO - ifconfig.me/ip
JScript
JS
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.open('GET', 'http://ifconfig.me/ip', false);
xmlhttp.send();
 
var ip = xmlhttp.responseText;
JS+XML
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.open('GET', 'http://ifconfig.me/all.xml', false);
xmlhttp.send();
 
var ip = xmlhttp.responseXml.getElementsByTagName('ip_addr')[0].text;
Having JSON library you can read and parse JSON data:
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.open('GET', 'http://ifconfig.me/all.json', false);
xmlhttp.send();
 
var data = JSON.parse(xmlhttp.responseText);
var ip = data.ip_addr;
VBScript
Dim xmlhttp, ip
 
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "GET", "http://ifconfig.me/ip", False
xmlhttp.send
 
ip = xmlhttp.responseText

No comments:

Post a Comment