Skip to content

Commit 24389fe

Browse files
committed
add php api
1 parent 13f10b0 commit 24389fe

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

ip-geolocation-api-php.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
<?php
3+
4+
$response = get_web_page("https://api.ipgeolocation.io/ipgeo?apiKey=d9d46f08bfb34ee59e4e8c74f07bb449&ip=103.255.5.105");
5+
$resArr = array();
6+
$resArr = json_decode($response);
7+
echo "<pre>"; print_r($resArr); echo "</pre>";
8+
9+
function get_web_page($url) {
10+
$cURL = curl_init();
11+
curl_setopt($cURL, CURLOPT_URL, $url);
12+
curl_setopt($cURL, CURLOPT_HTTPGET, true);
13+
14+
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
15+
'Content-Type: application/json',
16+
'Accept: application/json'
17+
));
18+
19+
$content = curl_exec($cURL);
20+
21+
curl_close($cURL);
22+
23+
return $content;
24+
}
25+
?>

0 commit comments

Comments
 (0)