Skip to content

Commit 2f8ae84

Browse files
authored
Update README.md
1 parent ad31817 commit 2f8ae84

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,44 @@
22

33
## Quick Start Guide
44

5-
Here is a complete example of code of php curl for ipgeolocation.
5+
Following is a php code snippet that gets the golocation data from the ip addess given.
66

7-
There is a methode get_web_page which takes url as parameter and return response from ipgeolocation.
7+
There is a methode get_web_page which takes url as parameter and returns the response from ipgeolocation. All you have to do is call the get_web_page function with the correct url
8+
9+
What constitutes a correct URL?
10+
the correct url is created by
811

912
Url takes one required parameter apiKey.
1013

11-
Note: This Url requires a valid IPGeolocation API key. Sign up if you don’t have one.
14+
Note: This Url requires a valid IPGeolocation API key. Sign up (https://ipgeolocation.io/signup?plan=1) if you don’t have one.
1215

1316
And replace 103.255.5.105 (ip) with your client ip.
1417

1518
```
1619
<?php
17-
$response = get_web_page("https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY&ip=103.255.5.105");
20+
$response = get_web_page("https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY&ip=YOUR_CLIENTS_IP");
21+
1822
$resArr = array();
1923
$resArr = json_decode($response);
24+
2025
echo "<pre>"; print_r($resArr); echo "</pre>";
26+
2127
function get_web_page($url) {
28+
2229
$cURL = curl_init();
30+
2331
curl_setopt($cURL, CURLOPT_URL, $url);
2432
curl_setopt($cURL, CURLOPT_HTTPGET, true);
25-
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
33+
34+
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
2635
'Content-Type: application/json',
2736
'Accept: application/json'
28-
));
37+
));
38+
2939
$content = curl_exec($cURL);
40+
3041
curl_close($cURL);
42+
3143
return $content;
3244
}
3345
?>

0 commit comments

Comments
 (0)