GeoIP Location and Real User Agent API

Started on the old forum in January 2012 · view the original in the archive · old links redirect here

No replies · 736 views · started 14 years ago · 1 min read

Anthony Developer · 82 posts #1

This script allows you to lookup GeoIP data of any IP address the function of this API outputs the following

->Country ->Region ->City ->Country Code ->ISP ->Real User Agent

<?php

$geo_ip=$_SERVER["REMOTE_ADDR"];
// Gets information about the current browser's user agent
   $gysms_server_link = "http://gysms.net/geo/?ip=$geo_ip";
   $host = $_SERVER['HTTP_HOST']; 
   $ch = curl_init() ;
   curl_setopt( $ch, CURLOPT_URL, $gysms_server_link ) ;
   curl_setopt( $ch, CURLOPT_HEADER, 0 ) ;
   curl_setopt( $ch, CURLOPT_FRESH_CONNECT, 1 ) ;
   curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ) ;
   curl_setopt($ch, CURLOPT_REFERER, $host);
   curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"] ) ;
   $result = curl_exec( $ch ) ;
   curl_close( $ch ) ;
  $details = json_decode($result);

$country = $details->country;
$region = $details->region;
$city = $details->city;
$country_code = $details->country_code;
$isp = $details->isp;
$browser = $details->browser;

echo "Country: <b>$country</b><br/>";

echo "Region: <b>$region</b><br/>";

echo "City: <b>$city</b><br/>";

echo "Country Code: <b>$country_code</b><br/>";

echo "ISP: <b>$isp</b><br/>";

echo "Real User Agent: <b>$browser</b><br/>";

?>

Demo here: http://gysms.net/tool

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close