PHP code example of peaky-blind3rs / ip-address-interface

1. Go to this page and download the library: Download peaky-blind3rs/ip-address-interface 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/ */

    

peaky-blind3rs / ip-address-interface example snippets


use PeakyBlind3rs\IpAddressInterface\Interface\Model\IpAddressInterface;
use PeakyBlind3rs\IpAddressInterface\IPServiceFactory;

$instance = IPServiceFactory::getInstance('ipinfo://nobody:[email protected]/?timeout=30');

$result = $instance->lookup('27.126.160.0');

if ($result instanceof IpAddressInterface) {
    // Request was successful, use getter methods to get data
} else {
    // Requested Ended in Error and $result hold instance of \Psr\Http\Message\ResponseInterface
}

use PeakyBlind3rs\IpAddressInterface\Interface\Model\IpAddressInterface;
use PeakyBlind3rs\IpAddressInterface\IPServiceFactory;

$instance = IPServiceFactory::getInstance('ipdata://nobody:[email protected]/?timeout=30');

$result = $instance->lookup('27.126.160.0');

if ($result instanceof IpAddressInterface) {
    // Request was successful, use getter methods to get data
} else {
    // Requested Ended in Error and $result hold instance of \Psr\Http\Message\ResponseInterface
}

namespace MyNamespace;

class MyAdapter implements \PeakyBlind3rs\IpAddressInterface\Interface\IpLookupInterface {

}


use MyNamespace\MyAdapter;
use PeakyBlind3rs\IpAddressInterface\IPServiceFactory;
use PeakyBlind3rs\IpAddressInterface\Interface\Model\IpAddressInterface;

IPServiceFactory::classMaps([
    'myadapter' => MyAdapter::class
]);

$instance = IPServiceFactory::getInstance('myadapter://nobody:[email protected]/?timeout=30');

$result = $instance->lookup('27.126.160.0');

if ($result instanceof IpAddressInterface) {
    // Request was successful, use getter methods to get data
} else {
    // Requested Ended in Error and $result hold instance of \Psr\Http\Message\ResponseInterface
}