Заголовок (тег title) |
Get Client's IP Address using JSON or Javascript |
Заголовок (тег h1) |
2.800.000.000 requests in the last 24 hoursObtaining Visitor's IP Address using JSONThis basic API permits you to get the public IP address of the system making the call.The function returns a JSON Text String with the IP address of the caller in either IPv4 or IPv6 format,depending on the requester's protocol.Syntax : https://l2.io/ip.json Try it!Get JSON User's IP addressIPv4 32-bit (four-byte) format, e.g. 195.80.156.70IPv6 128-bit format, e.g. 2a00:1b11:115:102:195:80:156:70If your script only supports IPv4 answers, you may want to use the following call to force IPv4:Syntax : https://www.l2.io/ip.json Try it!Get JSON User's IP addressIPv4 32-bit (four-byte) format, e.g. 195.80.156.70#curl https://l2.io/ip.json{"ip":"195.80.156.70"}#curl https://l2.io/ip.json?var=myip{"myip":"195.80.156.70"}Obtaining Visitor's IP Address in JavascriptThis API permits you to set the Javascript Variable of your choice with the public IP addressof the system making the call.The call returns a piece of Javascript Code with the IP address of the caller in either IPv4 or IPv6 format,depending on your request's protocol.The Variable Name is defined through the 'var' parameter.Syntax : Set javascript variable "myip" to client's IP addressIPv4 32-bit (four-byte) format, e.g. myip = "195.80.156.70";IPv6 128-bit format, e.g. myip = "2a00:1b11:115:102:195:80:156:70";If your script only supports IPv4 answers, you may want to use the following call instead :Syntax : Set javascript variable "myip" to client's IP addressIPv4 32-bit (four-byte) format, e.g. myip = "195.80.156.70";The following lines could be inserted into your HTML page.......Syntax : Display Client's IP address in your HTML page using javascript--> document.write('x.x.x.x');Get IP Address with a simple HTTP(s) requestThis basic API permits you to get the public IP address of the system making the call.The function returns a Text String with the IP address of the caller in either IPv4 or IPv6 format,depending on your request's protocol.Syntax : https://l2.io/ip Try it!Diplay/Get Plain Text User's IP addressIPv4 32-bit (four-byte) format, e.g. 195.80.156.70IPv6 128-bit format, e.g. 2a00:1b11:115:102:195:80:156:70If your script only supports IPv4 answers, you may want to use the following call to force IPv4:Syntax : https://www.l2.io/ip Try it!Diplay/Get Plain Text User's IP addressIPv4 32-bit (four-byte) format, e.g. 195.80.156.70The following examples show how you can use this API from various language.#shellperlpythonvb.net#!/bin/sh#Simple request using curl from a shell script.#If your OS supports a dual stack IPv4/IPv6 you can add -4 or -6 option#to force protocol selection, e.g. $(curl -4 -s https://l2.io/ip).myip=$(curl -s https://l2.io/ip)echo "My IP is $myip"#!/usr/bin/perl#Debian library : apt-get install libwww-perluse LWP::UserAgent;my $useragent = new LWP::UserAgent();my $myip = $useragent->get('https://l2.io/ip')->content;print 'My IP address is: '. $myip;#!/usr/bin/env python#Debian library : apt-get install python-requestsfrom requests import getmyip = get('https://l2.io/ip').textprint 'My IP address is: ', myipDim wc as New System.Net.WebClientDim myip as String = wc.DownloadString("https://l2.io/ip")MessageBox.Show(myip) |
Описание сайта (description) |
Get Client's IP Address using JSON or Javascript |
Ключевые слова (keywords) |
HTML, JSON, JavaScript, Client, Visitor, IP, Address |