File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments