{"id":21945870,"url":"https://github.com/ip2location/ip2location-php-api","last_synced_at":"2025-04-22T21:24:57.934Z","repository":{"id":56993026,"uuid":"111895658","full_name":"ip2location/ip2location-php-api","owner":"ip2location","description":"IP2Location PHP module provides an easy way to call the IP2Location API for geolocating an IP address and its country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.","archived":false,"fork":false,"pushed_at":"2024-01-03T06:18:37.000Z","size":14,"stargazers_count":13,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T21:16:49.501Z","etag":null,"topics":["geolocation","geolocation-api","ip-geolocation","ip-lookup","ip2location-api","ip2location-php","php-module"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ip2location.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-24T08:41:38.000Z","updated_at":"2023-08-18T15:13:12.000Z","dependencies_parsed_at":"2022-08-21T12:50:57.383Z","dependency_job_id":null,"html_url":"https://github.com/ip2location/ip2location-php-api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-php-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-php-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-php-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-php-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2location-php-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250326299,"owners_count":21412238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geolocation","geolocation-api","ip-geolocation","ip-lookup","ip2location-api","ip2location-php","php-module"],"created_at":"2024-11-29T04:19:54.039Z","updated_at":"2025-04-22T21:24:57.916Z","avatar_url":"https://github.com/ip2location.png","language":"PHP","readme":"# IP2Location PHP API\n\n\u003e This project has been merged into [IP2Location-PHP-Module](https://github.com/chrislim2888/IP2Location-PHP-Module). We will  no longer maintain and support this project. Please visit  [IP2Location-PHP-Module](https://github.com/chrislim2888/IP2Location-PHP-Module) for latest updates or enhancements.\n\nThis module allows user to geolocate the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, MCC, MNC, mobile brand name, elevation and usage type that any IP address or host name originates from by calling the **IP2Location API**.\n\n\n## Getting Started\nTo begin, an API key is required for this module to function. Find further information at https://www.ip2location.com/web-service\n\n\n\n## Usage\n\n```php\n\u003c?php\n\nrequire_once 'class.IP2LocationAPI.php';\n\n$apiKey = 'YOUR_API_KEY';\n$package = 'WS25'; // Package: WS1 - WS25\n$useSSL = false; // Use HTTP or HTTPS (Secure, but slower)\n\n$ip = '8.8.8.8';\n\n// Initialize\n$location = new IP2LocationAPI($apiKey, $package, $useSSL);\n\n/*\nTranslate country, region, and city name to desired language.\nRefer to product page for available language code.\n*/\n$location-\u003esetLanguage('zh-cn');\n\n/*\nEnable add ons to display more result.\nRefer to product page for available add ons.\n*/\n$location-\u003esetAddOns([\n\t'continent', 'country', 'region', 'city', 'geotargeting', 'country_groupings', 'time_zone_info',\n]);\n\n// Start query\nif (!$location-\u003equery($ip)) {\n\tdie('ERROR');\n}\n\necho '\u003cpre\u003e';\necho 'Country Code         : ' . $location-\u003ecountryCode . \"\\n\";\necho 'Country Name         : ' . $location-\u003ecountryName . \"\\n\";\necho 'Region Name          : ' . $location-\u003eregionName . \"\\n\";\necho 'City Name            : ' . $location-\u003ecityName . \"\\n\";\necho 'Latitude             : ' . $location-\u003elatitude . \"\\n\";\necho 'Longitude            : ' . $location-\u003elongitude . \"\\n\";\necho 'ZIP Code             : ' . $location-\u003ezipCode . \"\\n\";\necho 'Time Zone            : ' . $location-\u003etimeZone . \"\\n\";\necho 'ISP                  : ' . $location-\u003eisp . \"\\n\";\necho 'Domain               : ' . $location-\u003edomain . \"\\n\";\necho 'Latitude             : ' . $location-\u003enetSpeed . \"\\n\";\necho 'IDD Code             : ' . $location-\u003eiddCode . \"\\n\";\necho 'Area Code            : ' . $location-\u003eareaCode . \"\\n\";\necho 'Weather Station Code : ' . $location-\u003eweatherStationCode . \"\\n\";\necho 'Weather Station Name : ' . $location-\u003eweatherStationName . \"\\n\";\necho 'Mobile Brand         : ' . $location-\u003emobileBrand . \"\\n\";\necho 'Elevation            : ' . $location-\u003eelevation . \"\\n\";\necho 'Usage Type           : ' . $location-\u003eusageType . \"\\n\\n\";\necho 'Address Type         : ' . $location-\u003eaddressType . \"\\n\\n\";\necho 'Category             : ' . $location-\u003ecategory . \"\\n\\n\";\n\nif ($location-\u003econtinent) {\n\techo 'Continent Name       : ' . $location-\u003econtinent['name'] . \"\\n\";\n\techo 'Continent Code       : ' . $location-\u003econtinent['code'] . \"\\n\";\n\techo 'Hemisphere           : ' . $location-\u003econtinent['hemisphere'] . \"\\n\";\n\techo 'Localize Name        : ' . $location-\u003econtinent['translated'] . \"\\n\\n\";\n}\n\nif ($location-\u003ecountry) {\n\techo 'Country Name         : ' . $location-\u003ecountry['name'] . \"\\n\";\n\techo 'Localize Name        : ' . $location-\u003ecountry['translated'] . \"\\n\";\n\techo 'Alpha 3 Code         : ' . $location-\u003ecountry['alpha3Code'] . \"\\n\";\n\techo 'Numeric Code         : ' . $location-\u003ecountry['numericCode'] . \"\\n\";\n\techo 'Demonym              : ' . $location-\u003ecountry['demonym'] . \"\\n\";\n\techo 'Flag                 : ' . $location-\u003ecountry['flag'] . \"\\n\";\n\techo 'Capital              : ' . $location-\u003ecountry['capital'] . \"\\n\";\n\techo 'Total Area           : ' . $location-\u003ecountry['totalArea'] . \"\\n\";\n\techo 'Population           : ' . $location-\u003ecountry['population'] . \"\\n\";\n\techo 'Currency             : ' . $location-\u003ecountry['currencyName'] . ' (' . $location-\u003ecountry['currencyCode'] . ', ' . $location-\u003ecountry['currencySymbol'] . ')' . \"\\n\";\n\techo 'Language             : ' . $location-\u003ecountry['languageName'] . ' (' . $location-\u003ecountry['languageCode'] . ')' . \"\\n\";\n\techo 'IDD Code             : ' . $location-\u003ecountry['iddCode'] . \"\\n\";\n\techo 'TLD                  : ' . $location-\u003ecountry['tld'] . \"\\n\\n\";\n}\n\nif ($location-\u003eregion) {\n\techo 'Region Name          : ' . $location-\u003eregion['name'] . \"\\n\";\n\techo 'Localize Name        : ' . $location-\u003eregion['translated'] . \"\\n\";\n\techo 'Region Code          : ' . $location-\u003eregion['code'] . \"\\n\\n\";\n}\n\nif ($location-\u003ecity) {\n\techo 'City Name            : ' . $location-\u003ecity['name'] . \"\\n\";\n\techo 'Localize Name        : ' . $location-\u003ecity['translated'] . \"\\n\\n\";\n}\n\nif ($location-\u003egeotargeting) {\n\techo 'Metro Code           : ' . $location-\u003egeotargeting['metro'] . \"\\n\\n\";\n}\n\nif ($location-\u003ecountryGroupings) {\n\tforeach ($location-\u003ecountryGroupings as $group) {\n\t\techo 'Group of             : ' . $group-\u003ename . ' (' . $group-\u003eacronym . ')' . \"\\n\";\n\t}\n\n\techo \"\\n\";\n}\n\nif ($location-\u003etimeZoneInfo) {\n\techo 'Olson                : ' . $location-\u003etimeZoneInfo['olson'] . \"\\n\";\n\techo 'Current Time         : ' . $location-\u003etimeZoneInfo['currentTime'] . \"\\n\";\n\techo 'GMT Offset           : ' . $location-\u003etimeZoneInfo['gmtOffset'] . \"\\n\";\n\techo 'DST                  : ' . $location-\u003etimeZoneInfo['isDST'] . \"\\n\";\n}\n\necho '\u003c/pre\u003e';\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-php-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2location-php-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-php-api/lists"}