OpenCrypt - Membership Software
Username:
Password:
Register / My Account / Forgotten Password?
 Home  Features and Benefits  Online Demonstration  Purchase  Our Services  Help and Support  my.OpenCrypt 
 Welcome  New Visitor  Latest NewsRSS Feed Company Information  Press/Testimonials  Frequently Asked Questions  BlogNew Content
IP Location API
Saturday 5th September 2009

IP Location API We are very pleased to announce the launch of our OpenCrypt IP Location API service. The IP Location API enables you to detect user location based on a user's IP address. Quite simply, you provide the API with an IP address and it returns the country that IP is registered to.
 
The IP Location API is integrated with OpenCrypt version 1.8 to offer improved statistics which now include user locations and usage per country data. However, the API isn't just for use with OpenCrypt, we invite all developers to use the API with their own tools and services.
 
API Registration

To register an IP Location API Key please login to the IP Location section of my.OpenCrypt: http://my.opencrypt.com/ip-location.php
 
All new API keys are assigned 50,000 free credits. 100,000 additional credits can be purchased for £5 and 1,000,000 credits can be purchased for £30.
 
API Usage

Once you have your API Key, you can connect to the API using the following URL: http://api.opencrypt.com/ip/?IP=255.255.255.255&key=0XXX-00XX-XX00-XXX0
 
Replace 255.255.255.255 with the IP address you want to lookup, and replace 0XXX-00XX-XX00-XXX0 with your API Key.
 
The response returned will be:

IP=255.255.255.255
CC=GB
CN=United Kingdom
 
If you are out of lookup credits, the response will be:

OUT OF CREDITS
 
If the response is blank, the API Key is invalid.
 
When an invalid IP address is used, the country code is returned as ZZ.
 
PHP Example

The following is an example PHP script for retrieving IP location information using the API, the example script includes a collection of country flag images which can be used to help identify the country the IP is registered to.
 

PHP Example Usage

To use the PHP example, simply extract the files from the ZIP file and upload to your web server. In ip_location.php, update the $path_images and $url_images variables to reflect the server path and URL to the directory containing the flag images.
 
The following code is used in example.php to connect to the IP Location API:

require_once("ip_location.php");
$ip_result = get_ip_country("IP ADDRESS","API-KEY");
 
This code returns an array containing the API response data. The response values are as follows:
 
$ip_result['ip'] - The IP address the data is for. e.g. 255.255.255.255
$ip_result['cc'] - The two letter country code. e.g. US
$ip_result['cn'] - The name of the country. e.g. United States
$ip_result['cf'] - The flag for the country.
 
Note, to reduce unnecessary API requests it is recommended you setup some form of cache for storing IP address lookups. For example, OpenCrypt allows you to select how long IP location data should be stored for, by default this is 30 days. This means the system only connects to the API once every 30 days for each IP address looked up which significantly reduces the number of API requests.
 
Share this article:
Delicious Stumble It!
Stumble It!
 
<- Integrating OpenCrypt's PHP Login Interface
 
We're on Twitter! ->
Articles
Subscribe to RSS Feed
OpenCrypt Version 1.9
New Product: myRepono Website Backup Service
Website Pre-Launch Checklist
ionix in 2010
PHP Security Tips - Part 1
OpenCrypt 1.8 New Feature Highlights
Video Conversion API
We're on Twitter!
IP Location API
Integrating OpenCrypt's PHP Login Interface
Developing Mobile Web Sites
Service Recovery
Building relationships with your customers
Doing the unexpected
PHP/JavaScript World Map with Continent and Ocean Selection
We've Moved!
Customer Showcase: A-Z-Animals.com
Optimising your secure content for Google
Membership business models
AJAX Calendar with PHP and mySQL
PHP Function for Reciprocal Linkback Checking
AJAX Tree Menu with PHP - Revisited
What is membership software?
Login form designs and inspiration
PHP subscriber counter with Addicted to Feedburner class and Feedburner Awareness API
AJAX Tree Menu with PHP
AJAX data listings engine with PHP and mySQL (BETA)
Join the ionix Team!
Press Release: OpenCrypt 2.0 in Development!
PHP: Basic functions for quickstart PHP framework
Welcome to the OpenCrypt Blog!
Visitor Comments
OpenCrypt Team 10 out of 10
Space Holder
Please note the change in the API URL on the 18th Sep 09. The old URL will continue to be available until it is no longer being used, though we recommend you update your code to use the new URL which is hosted on a separate server specifically for our APIs.
Space Holder
Space Holder
Average Rating: 9.73 out of 10 (49 Votes)
Space Holder
Submit Comment
Space Holder
Article Rating:
Space Holder
Your Name:
Space Holder
Your Comment/Response:
Space Holder
Space Holder
Space Holder

Follow us on Twitter

Copyright © 1999 - 2011 ionix Limited. Affiliates, Contact Us

Powered by OpenCrypt Membership Software, Backups by myRepono Website Backup