Skip to content

Commit ad31817

Browse files
authored
Update README.md
1 parent 9fb3660 commit ad31817

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
# ip-geolocation-api-php
1+
# ip-geolocation-api-php
2+
3+
## Quick Start Guide
4+
5+
Here is a complete example of code of php curl for ipgeolocation.
6+
7+
There is a methode get_web_page which takes url as parameter and return response from ipgeolocation.
8+
9+
Url takes one required parameter apiKey.
10+
11+
Note: This Url requires a valid IPGeolocation API key. Sign up if you don’t have one.
12+
13+
And replace 103.255.5.105 (ip) with your client ip.
14+
15+
```
16+
<?php
17+
$response = get_web_page("https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY&ip=103.255.5.105");
18+
$resArr = array();
19+
$resArr = json_decode($response);
20+
echo "<pre>"; print_r($resArr); echo "</pre>";
21+
function get_web_page($url) {
22+
$cURL = curl_init();
23+
curl_setopt($cURL, CURLOPT_URL, $url);
24+
curl_setopt($cURL, CURLOPT_HTTPGET, true);
25+
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
26+
'Content-Type: application/json',
27+
'Accept: application/json'
28+
));
29+
$content = curl_exec($cURL);
30+
curl_close($cURL);
31+
return $content;
32+
}
33+
?>
34+
```

0 commit comments

Comments
 (0)