Allows lookup the location of any IP address

v2.0 2020-11-09 09:49 UTC

This package is auto-updated.

Last update: 2024-04-29 04:27:21 UTC


README

Plugin allows lookup the location of any IP address

website

https://ipdata.co/

link to documentation

https://docs.ipdata.co/

How to use

  • As a shared service from json file

Create file in json format and save in desired folder

{
        "sharedServices": {
            "ipdata": {
                "className": "\\PhalconPlugins\\IpData",
                "properties": [
                    {
                        "name": "apiKey",
                        "value": {
                            "type": "parameter",
                            "value": "your-ip-data-api-key"
                        }
                    },
                    {
                        "name": "baseUrl",
                        "value": {
                            "type": "parameter",
                            "value": "https://api.ipdata.co"
                        }
                    }
                ]
            }
        }
}

In your application read the file with Phalcon Json adatper an Load as a shared service

$sharedServices = new Phalcon\Config\Adapter\Json('path-to-json-file-with-shared-services');

foreach ($sharedServices->path('sharedServices', []) as $shareName => $options) {

    $di->setShared($shareName, $options->toArray());
    
};

Call anywere in your application ( controllers or plugins )

$ipdata = $this->ipdata->locate('ip-address-to-locate');

  • As a instance of class
$ipdata = new PhalconPlugins\IpData();

$ipdata->setApiKey('your-api-key');

$ipdata->setBaseUrl('https://api.ipdata.co');

$data = $ipdata->locate('ip-address-to-locate');