IP address query

Source: Internet
Author: User

I believe that many peopleProgramIn the design, I thought about querying the actual address of the user based on the user's IP address.

This function is not widely used, but if it is used, it will add a lot of points to the user experience of your program, such:

When a user registers, the "location" column is displayed in a drop-down box. In the past, it was shown that "Beijing", "select Province", and "select city, some users may choose either of them;

But honest users will always find the correct local address for half a day, which will give the user a poor experience. When you open the registration page, you can use this function to display the IP address in the drop-down list.

In addition, it can be combined with the weather forecast API to pass the address to it. However, most of the weather forecast APIs are intelligent and the user's local information is automatically displayed.

Next I will introduce you to the APIs for querying IP addresses:

One, Teng Xun an API, that is, http://fw.qq.com/ipaddress

If you directly go to this address, you will find that in the browser: var ipdata = new array ("220. 175. *. * "," "," Jiangxi Province "," Nanchang City ");Note: "*" is changed. It returns the complete IP address.

This indicates that it returns a piece of JavaScriptCodeNow we want to reference it very conveniently.

 

<SCRIPT type = "text/JavaScript" src = "http://fw.qq.com/ipaddress"> </SCRIPT>

If you want to call provinces and municipalities, you can directly use ipdata [2] and ipdata [3].

 

2, provided by ip2loc, see: http://ip2loc.appspot.com/(the following content from the official website,)

======================================

This feature is a little more powerful, but it is a knife, you must provide IP addresses, it is a little more troublesome; if you want to do a query-type website, it is very good.

 

In fact, there are still a lot of such APIs available in Sina and Sohu, so we will not discuss them here.

This can also be used for verification. It is to determine whether the selected location matches the location queried by IP address. Otherwise, a friendly reminder is given, but it is best not to force a match.

-_-.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.