Get IP Details Via API with PHP

ipapi.com is a API for getting IP address details. You can use this to redirect users to different websites depending on the country access.

This is a short tutorial on how to get IP Address details with API ipapi.com 

<?php
    echo file_get_contents('https://ipapi.co/8.8.8.8/json');
?>

Sample Response:

{
    "ip": "8.8.8.8",
    "city": "Mountain View",
    "region": "California",
    "region_code": "CA",
    "country": "US",
    "country_code": "US",
    "country_code_iso3": "USA",
    "country_capital": "Washington",
    "country_tld": ".us",
    "country_name": "United States",
    "continent_code": "NA",
    "in_eu": false,
    "postal": "Sign up to access",
    "latitude": "Sign up to access",
    "longitude": "Sign up to access",
    "timezone": "America/Los_Angeles",
    "utc_offset": "-0700",
    "country_calling_code": "+1",
    "currency": "USD",
    "currency_name": "Dollar",
    "languages": "en-US,es-US,haw,fr",
    "country_area": 9629091.0,
    "country_population": 310232863.0,
    "message": "Please message us at ipapi.co/trial for full access",
    "asn": "AS15169",
    "org": "GOOGLE"
}