PHP code example of abdullah-karam / usergeolocationapi

1. Go to this page and download the library: Download abdullah-karam/usergeolocationapi 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/ */

    

abdullah-karam / usergeolocationapi example snippets



use Abdullah\UserGeoLocation\GeoLocation;

$user_ip = request()->ip();

$userInfo = new GeoLocation($user_ip);

echo $userInfo->getUserIP();
result : 141.201.183.207

you can chain on object 
to get all information about user like this

dd($userInfo->getUserInfo());

result : Abdullah\UserGeoLocation\GeoLocation {#281 ▼
  -Service_url: "http://ip-api.com/php/"
  -USER_IP: "41.46.3.168"
  -Query: "status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query ◀"
  -USER_INFO: array:24 [▼
    "status" => "success"
    "continent" => "Africa"
    "continentCode" => "AF"
    "country" => "Egypt"
    "countryCode" => "EG"
    "region" => "C"
    "regionName" => "Cairo Governorate"
    "city" => "Cairo"
    "district" => ""
    "zip" => ""
    "lat" => 30.0**
    "lon" => 31.28**
    "timezone" => "Africa/Cairo"
    "offset" => 7200
    "currency" => "EGP"
    "isp" => "TE Data"
    "org" => ""
    "as" => "AS8452 TE-AS"
    "asname" => "TE-AS"
    "reverse" => "host-41.4**.3.1**.tedata.net"
    "mobile" => false
    "proxy" => false
    "hosting" => false
    "query" => "4*.4*.3.1**"
  ]