PHP code example of gemz / geoip

1. Go to this page and download the library: Download gemz/geoip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gemz / geoip example snippets

 php
use \Gemz\GeoIp\GeoIp;

// get by domain
$result = GeoIp::for('gemz.io')->get();

// get by ip
$result = GeoIp::for('52.59.200.190')->get();

// result in specific locale
// supported are de, en, fr, es default is en
$result = GeoIp::for('gemz.io')->locale('en')->get();

// response is an array with these values
array:17 [
  "status" => "success"
  "country" => "Germany"
  "countryCode" => "DE"
  "region" => "HE"
  "regionName" => "Hesse"
  "city" => "Frankfurt am Main"
  "zip" => "60313"
  "lat" => 50.1109
  "lon" => 8.68213
  "timezone" => "Europe/Berlin"
  "isp" => "Amazon Technologies Inc."
  "org" => "AWS EC2 (eu-central-1)"
  "as" => "AS16509 Amazon.com, Inc."
  "asname" => "AMAZON-02"
  "reverse" => "ec2-52-59-200-190.eu-central-1.compute.amazonaws.com"
  "proxy" => false
  "query" => "52.59.200.190"
]

// if request is not successful
[
    "status" => "fail",
    "query" => "notvalid domain",
]