Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function getGeoInfo(string $ip) : object |
||
20 | { |
||
21 | $key = require(ANAX_INSTALL_PATH . "/config/api_key.php"); |
||
22 | $api_key = $key["ipstack"]; |
||
23 | $url = "http://api.ipstack.com/$ip?access_key=$api_key"; |
||
24 | $ch = curl_init(); |
||
25 | |||
26 | curl_setopt($ch, CURLOPT_URL, $url); |
||
|
|||
27 | curl_setopt($ch, CURLOPT_HEADER, 0); |
||
28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
29 | |||
30 | $info = curl_exec($ch); |
||
31 | curl_close($ch); |
||
32 | return json_decode($info); |
||
33 | } |
||
35 |