1 | <?php |
||
12 | class IpinfoApi |
||
13 | { |
||
14 | const BASE_URL = 'http://ipinfo.io/'; |
||
15 | const GEO = 'geo'; |
||
16 | const TOKEN = 'token'; |
||
17 | |||
18 | |||
19 | /** @var array */ |
||
20 | protected $settings; |
||
21 | |||
22 | |||
23 | /** |
||
24 | * IpinfoApi constructor. |
||
25 | * @param array|null $settings An array with all the settings. |
||
26 | * Supported keys are: |
||
27 | * - token: string the developer token; |
||
28 | */ |
||
29 | public function __construct($settings = array()) |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Get all the info about your own ip address. |
||
39 | * |
||
40 | * @return IpinfoResponse |
||
41 | */ |
||
42 | public function getYourOwnIpDetails() |
||
48 | |||
49 | |||
50 | /** |
||
51 | * Get all the info about an ip address. |
||
52 | * |
||
53 | * @param string $ipAddress |
||
54 | * @return IpinfoResponse |
||
55 | */ |
||
56 | public function getFullIpDetails($ipAddress) |
||
62 | |||
63 | |||
64 | /** |
||
65 | * Use the /geo call to get just the geolocation information, which will often be |
||
66 | * faster than getting the full response. |
||
67 | * |
||
68 | * @param string $ipAddress |
||
69 | * |
||
70 | * @return IpinfoResponse |
||
71 | */ |
||
72 | public function getIpGeoDetails($ipAddress) |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Make a curl request. |
||
82 | * |
||
83 | * @param string $address The address of the request. |
||
84 | * |
||
85 | * @return JsonResponse Returns the response from the request. |
||
86 | */ |
||
87 | protected function sendRequest($address) |
||
109 | } |
||
110 |