Lookup Method
This method is used to retrieve the information of a specific IP Address.
Option | Type | Description |
---|---|---|
ip * | String | The IP Address you want to lookup. |
params | Array | Specifies the modules you want to retrieve as visitor information.
It's an Array of consist some Strings as it's items.
Accepts: location , security , timezone , currency and/or device .
Default: [] |
lang | String | Specifies the API output language.
Accepts: EN , AR , DE , FR , ES , JA , JA , ZH or RU .
Default: EN |
mode | String | You can use this option for using the Development Environment of the API, read more.
Accepts: live or test .
Default: live |
Parameters with the (*) are required.
Basic example of using this method:
// Calling the `lookup` methodand storing the
// response in a new variable called `$GREGeoIP_Response`
$GREGeoIP_Response = $GREGeoIP->lookup(
'1.1.1.1' // <-- The IP Address you want to lookup
);
// Printing the response
print_r($GREGeoIP_Response); // array of data
Description:
This method accepts 4 parameters represents the options you want to specify for this method (See the Options table above). Let's dive into this:
Let's say that we want to retrieve the location information, timezone and device information of a specific IP Address. So the code will be like this:
$GREGeoIP_Response = $GREGeoIP->lookup(
'1.1.1.1', // The IP Address you want to lookup
['timezone', 'device'] // The params array contains the modules you want
);
// Printing the response
print_r($GREGeoIP_Response);
Beside this, we can inform the module to return the response in
English
:$GREGeoIP_Response = $GREGeoIP->lookup(
'1.1.1.1',
['timezone', 'device'],
'EN' // The API output language will be English
);
// Printing the response
print_r($GREGeoIP_Response);
And so on...
You can use the
isError
method to check if everything going well after calling each method:$GREGeoIP_Response = $GREGeoIP->lookup(
'1.1.1.1',
['timezone', 'device'],
'EN'
);
// Check if there's no error returned then print the response
if (!$GREGeoIP_Response->isError){
print_r($GREGeoIP_Response);
}
The
isError
method returns a boolean value.
If it's true
then there's an error occurred and the data hasn't fetched.
This method will return true
only if there's something wrong with your integration. So, please check your code if you see it returns true
.Last modified 11mo ago