|
1 | | -# IP Geolocation API PHP SDK |
2 | | -You need a valid IPGeolocation API key to use this SDK. [Sign up](https://ipgeolocation.io/signup) here, if you don’t have the API key. |
| 1 | +# IP Geolocation API Typescript SDK |
| 2 | + |
| 3 | +## Introduction |
| 4 | +IPGeolocation API is the solution to identify country code (ISO2 and ISO3 standard), country name, continent code, continent name, country capital, state/province, district, city, zip code, latitude and longitude of city, is country belongs to Europian Union, calling code, top level domain (TLD), languages, country flag, internet service provider (ISP), connection type, organization, geoname ID, currency code, currency name, time zone ID, time zone offset, current time in the time zone, is time zone in daylight saving time, and total daylight savings. This document provides important information to help you get up to speed with IPGeolocation API using IP Geolocation API PHP SDK. |
| 5 | + |
| 6 | +Developers can use this Typescript SDK for software and web projects related to, but not limited to: |
| 7 | + |
| 8 | +* Display native language and currency |
| 9 | +* Redirect based on the country |
| 10 | +* Digital rights management |
| 11 | +* Web log stats and analysis |
| 12 | +* Auto-selection of country, state/province and city on forms |
| 13 | +* Filter access from countries you do not do business with |
| 14 | +* Geo-targeting for increased sales and click-through |
3 | 15 |
|
4 | 16 | ## Quick Start Guide |
5 | | -Call method **get_location($apikey, $clientIp)** passing *API key* and *IP address (optional)* as parameters and it will return IPGeolocation API response. |
6 | | -Note: If you want IP to geolocation for machine calling IPGeolocation API, don't pass the *IP address* parameter. |
| 17 | +In this document, you will go through the basic steps to use IP Geolocation API PHP SDK. |
| 18 | +You need a valid 'IPGeolocation API key' to use this SDK. [Sign up](https://ipgeolocation.io/signup) here and get your free API key if you don't have one. |
| 19 | + |
| 20 | +## System Requirements |
| 21 | +Internet connection is required to run this component. |
| 22 | + |
| 23 | +## Basic Usage |
| 24 | +Call method **get_location($apikey, $clientIp)** passing *IP address (optional)* and *API key* as parameters and it will return IP Geolocation API response. |
| 25 | +Note: If you want IP to geolocation for the machine calling IPGeolocation API, leave out the *IP address* parameter. |
7 | 26 |
|
8 | | -### Basic Usage |
9 | 27 | ```php |
10 | 28 | <?php |
11 | 29 | $clientIp = "IP_ADDRESS"; |
12 | 30 | $apikey = "YOUR_API_KEY"; |
13 | | - |
14 | 31 | $response = get_location($apikey, $clientIp); |
15 | 32 | $resArr = array(); |
16 | 33 | $resArr = json_decode($response); |
17 | | - |
18 | 34 | echo "<pre>"; print_r($resArr); echo "</pre>"; |
| 35 | + |
19 | 36 | function get_location($apiKey, $ip = null) { |
20 | 37 | $url = "https://api.ipgeolocation.io/ipgeo?apiKey=".$apiKey."&ip=".$ip; |
21 | 38 | $cURL = curl_init(); |
| 39 | + |
22 | 40 | curl_setopt($cURL, CURLOPT_URL, $url); |
23 | 41 | curl_setopt($cURL, CURLOPT_HTTPGET, true); |
24 | | - |
25 | 42 | curl_setopt($cURL, CURLOPT_HTTPHEADER, array( |
26 | 43 | 'Content-Type: application/json', |
27 | 44 | 'Accept: application/json' |
|
0 commit comments