GetYourBit.com client
This library allows you to make requests easily.
require 'vendor/autoload.php';
use GetYourBit\Api;
// create an instance
$api = new Api('https://ip.getyourbit.com/');
// login
$api->auth('login', 'password');
// request without scrolling
$body = $api->request("/lookup/8.8.8.8", array('locale': 'en-US'));
var_dump($body['data']);
// request with scrolling
$result = $api->scroll("/find/", array(
'size': 500,
'query' => array(
'country' => 'nepal'
)
));
echo count($result);
//logout
$api->logout();
Login to the API. You can get $login and $password on the site after a subscription.
$options is requests module options.
You can also pass headers as option
Free services don't require authorization.
Logout from the API. It gives an error without authorization before.
Request to the API without scrolling to get data.
It returns all response body as object.
Request to the API with scrolling to get data. You can pass callback to control every chunk. You will get three arguments:
- $body - chunk response body
- $chunkData - chunk data
- $fullData - full data by the current chunk
It returns the full data at the end