66.gif

Search (advanced search)
Use this Search form before posting, asking or make a new thread.
Tips: Use Quotation mark to search words (eg. "How To Make Money Online")

01-15-2015, 03:51 AM
Post: #1
Include your visitors location in the website
Hi everyone!

This tutorial (if you can even call it that) is really short but might be useful if you want to find out your website visitors location and include it in the page or deliver geo-tailored content.

This uses the following website:
Code:
http://ipinfo.io

They have an API for looking up info about any IP.
Here's the documentation:
Code:
http://ipinfo.io/developers
(1000 API calls per day are free)

The following two lines of code is how to find out your visitor's city (for the other API functions please refer to the documentation).

PHP (sorry if you want other programming language, I only know php):
PHP Code:
$ip $_SERVER['REMOTE_ADDR'];
$city file_get_contents('http://ipinfo.io/' $ip '/city'); 

If you want more than one info field about a single IP, you should make a JSON call (as shown in the documentation) and parse the JSON response. Otherwise you could use up your free API requests really quick.
02-06-2015, 08:32 AM
Post: #2
RE:
Thank you for the share. Bookmarking for just in case.
02-10-2015, 11:39 PM
Post: #3
RE:
great share, thx.




26.gif