{"id":4225,"date":"2019-11-21T17:43:52","date_gmt":"2019-11-21T17:43:52","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=4225"},"modified":"2021-05-10T14:26:49","modified_gmt":"2021-05-10T14:26:49","slug":"geolocation-from-ip-address-using-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/","title":{"rendered":"Geolocation from IP Address using PHP"},"content":{"rendered":"<p>The <b>Geolocation API<\/b> allows the developer to get the location information from the IP address and track the visitors in the web application. It returns realtime geolocation data based on the IP address specified in the API URL. The Geolocation API is very useful when you want to locate the website visitors and adjust the functionality accordingly.<\/p>\n<p>There are various Geolocation API available to get the geolocation info from IP, <b>ipstack<\/b> is one of the best free Geolocation API among them. Ipstack API enables you to identify the web user&#8217;s by their IP address in realtime. Ipstack provides powerful Geolocation API that looking up location data and returns accurate info in JSON or XML format. The ipstack API can be used in any programming language (PHP, JavaScript, etc.) to get the geolocation data. In this tutorial, we will show you how to <b>get geolocation from IP address using PHP<\/b>.<\/p>\n<p>Follow the below simple steps to integrate <b>Geolocation API with ipstack in PHP<\/b>.<\/p>\n<h2>Get API Access Key<\/h2>\n<p>In order to authenticate with ipstack API, a unique authentication key is required. Before getting started, create your <b>API Access Key<\/b>.<\/p>\n<ul class=\"step_list\">\n<li>Create an account on <a href=\"https:\/\/ipstack.com\/product\" target=\"_blank\" rel=\"noopener noreferrer\">ipstack<\/a>.<\/li>\n<li>In the dashboard, you will get the API key under the <b>Your API Access Key<\/b>.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/serp-api-access-key-codexworld.png\" alt=\"geolocation-api-access-key-codexworld\" width=\"976\" height=\"399\" class=\"alignnone size-full wp-image-4204\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/serp-api-access-key-codexworld.png 976w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/serp-api-access-key-codexworld-300x123.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/serp-api-access-key-codexworld-768x314.png 768w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/serp-api-access-key-codexworld-200x82.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/serp-api-access-key-codexworld-346x141.png 346w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/div>\n<\/li>\n<\/ul>\n<h2>API Configuration<\/h2>\n<p>To get the geolocation data from ipstack API, specify API Access Key and IP address.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Append IP address to the API&#8217;s base URL.<\/li>\n<li>Specify the API Access Key in the <code>access_key<\/code> parameter.<\/li>\n<\/ul>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;IP&nbsp;address&nbsp;and&nbsp;API&nbsp;access&nbsp;key&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$ip&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'38.132.116.186'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$access_key&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_ACCESS_KEY'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;API&nbsp;URL <br \/><\/span><span style=\"color: #0000BB\">$apiURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'http:\/\/api.ipstack.com\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$ip<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'?access_key='<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$access_key<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<h2>Make HTTP GET Request<\/h2>\n<p>To fetch the geolocation data, call Geolocation API via HTTP GET request using <a href=\"https:\/\/www.codexworld.com\/post-receive-json-data-using-php-curl\/\">cURL in PHP<\/a>.<\/p>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;API&nbsp;URL <br \/><\/span><span style=\"color: #0000BB\">$apiURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'http:\/\/api.ipstack.com\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$ip<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'?access_key='<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$access_key<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Initialize&nbsp;cURL <br \/><\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">(); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;URL&nbsp;and&nbsp;other&nbsp;appropriate&nbsp;options <br \/><\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$apiURL<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Execute&nbsp;and&nbsp;get&nbsp;response&nbsp;from&nbsp;API <br \/><\/span><span style=\"color: #0000BB\">$json_resp&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Close&nbsp;cURL <br \/><\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<p><b>HTTPS Encryption:<\/b><br \/>\nTo make secure API request use HTTPS (SSL) encryption by calling API URL begins with an <code>https<\/code>.<\/p>\n<pre>https:\/\/api.ipstack.com<\/pre>\n<h2>Geolocation Data<\/h2>\n<p>After a successful API request, the geolocation data can be returned in JSON or XML format. Initially, the ipstack API returns the following geolocation data.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>IP Address (ip)<\/li>\n<li>Type (type)<\/li>\n<li>Continent Code (continent_code)<\/li>\n<li>Continent Name (continent_name)<\/li>\n<li>Country Code (country_code)<\/li>\n<li>Country Name (country_name)<\/li>\n<li>Region Code (region_code)<\/li>\n<li>Region Name (region_name)<\/li>\n<li>City (city)<\/li>\n<li>Zipcode (zip)<\/li>\n<li>Latitude (latitude)<\/li>\n<li>Longitude (longitude)<\/li>\n<li>Location (location)\n<ul>\n<li>geoname_id<\/li>\n<li>capital<\/li>\n<li>languages<\/li>\n<li>country_flag<\/li>\n<li>country_flag_emoji<\/li>\n<li>country_flag_emoji_unicode<\/li>\n<li>calling_code<\/li>\n<li>is_eu<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Use <code>json_decode()<\/code> function to convert the JSON response to array in PHP.<\/p>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Convert&nbsp;API&nbsp;json&nbsp;response&nbsp;to&nbsp;array <br \/><\/span><span style=\"color: #0000BB\">$api_result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$json_resp<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<h2>Example Code to Get Geolocation from IP via ipstack API<\/h2>\n<p>The following are the complete code to get geolocation from IP address using PHP.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;IP&nbsp;address&nbsp;and&nbsp;API&nbsp;access&nbsp;key&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$ip&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'38.132.116.186'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$access_key&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'YOUR_ACCESS_KEY'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;API&nbsp;URL <br \/><\/span><span style=\"color: #0000BB\">$apiURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'http:\/\/api.ipstack.com\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$ip<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'?access_key='<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$access_key<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Initialize&nbsp;cURL <br \/><\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">(); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;URL&nbsp;and&nbsp;other&nbsp;appropriate&nbsp;options <br \/><\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$apiURL<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Execute&nbsp;and&nbsp;get&nbsp;response&nbsp;from&nbsp;API <br \/><\/span><span style=\"color: #0000BB\">$json_resp&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Close&nbsp;cURL <br \/><\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Geolocation&nbsp;data <br \/><\/span><span style=\"color: #0000BB\">$api_result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$json_resp<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/get-geolocation-country-latitude-longitude-from-ip-address-using-php\/\">Get Geolocation (Country, Latitude, and Longitude) from IP Address using PHP<\/a><\/span><\/p>\n<h2>Conclusion<\/h2>\n<p>The ipstack API is free to use, there also premium plans are available for advanced uses. In the example code, the most required geolocation data is fetched from the ipstack API with minimal configuration. You can use additional parameters to customize the API result and get geolocation data as per your needs. For a complete reference, see the <a href=\"https:\/\/ipstack.com\/documentation\" target=\"_blank\" rel=\"noopener noreferrer\">documentation of ipstack API<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Geolocation API allows the developer to get the location information from the IP address and track the visitors in the web application. It returns realtime geolocation data based on the IP address specified in <\/p>\n","protected":false},"author":1,"featured_media":4227,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[250,103,269,14],"class_list":["post-4225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-api","tag-geolocationapi","tag-ip","tag-php","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Geolocation from IP Address using PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"Geolocation API with PHP - Get geolocation data from IP address with ipstack API in PHP. Use ipstack free Geolocation API to get the location info using PHP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Geolocation from IP Address using PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Geolocation API with PHP - Get geolocation data from IP address with ipstack API in PHP. Use ipstack free Geolocation API to get the location info using PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2019-11-21T17:43:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-10T14:26:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Geolocation from IP Address using PHP\",\"datePublished\":\"2019-11-21T17:43:52+00:00\",\"dateModified\":\"2021-05-10T14:26:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/\"},\"wordCount\":478,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/geolocation-from-ip-address-using-php-codexworld.jpg\",\"keywords\":[\"API\",\"GeolocationAPI\",\"IP\",\"PHP\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/\",\"name\":\"Geolocation from IP Address using PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/geolocation-from-ip-address-using-php-codexworld.jpg\",\"datePublished\":\"2019-11-21T17:43:52+00:00\",\"dateModified\":\"2021-05-10T14:26:49+00:00\",\"description\":\"Geolocation API with PHP - Get geolocation data from IP address with ipstack API in PHP. Use ipstack free Geolocation API to get the location info using PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/geolocation-from-ip-address-using-php-codexworld.jpg\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/geolocation-from-ip-address-using-php-codexworld.jpg\",\"width\":1366,\"height\":768,\"caption\":\"geolocation-from-ip-address-using-php-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/geolocation-from-ip-address-using-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Geolocation from IP Address using PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Geolocation from IP Address using PHP - CodexWorld","description":"Geolocation API with PHP - Get geolocation data from IP address with ipstack API in PHP. Use ipstack free Geolocation API to get the location info using PHP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/","og_locale":"en_US","og_type":"article","og_title":"Geolocation from IP Address using PHP - CodexWorld","og_description":"Geolocation API with PHP - Get geolocation data from IP address with ipstack API in PHP. Use ipstack free Geolocation API to get the location info using PHP.","og_url":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2019-11-21T17:43:52+00:00","article_modified_time":"2021-05-10T14:26:49+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg","type":"image\/jpeg"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Geolocation from IP Address using PHP","datePublished":"2019-11-21T17:43:52+00:00","dateModified":"2021-05-10T14:26:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/"},"wordCount":478,"commentCount":0,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg","keywords":["API","GeolocationAPI","IP","PHP"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/","url":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/","name":"Geolocation from IP Address using PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg","datePublished":"2019-11-21T17:43:52+00:00","dateModified":"2021-05-10T14:26:49+00:00","description":"Geolocation API with PHP - Get geolocation data from IP address with ipstack API in PHP. Use ipstack free Geolocation API to get the location info using PHP.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg","width":1366,"height":768,"caption":"geolocation-from-ip-address-using-php-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/geolocation-from-ip-address-using-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Geolocation from IP Address using PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2019\/11\/geolocation-from-ip-address-using-php-codexworld.jpg","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-169","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=4225"}],"version-history":[{"count":2,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4225\/revisions"}],"predecessor-version":[{"id":4646,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4225\/revisions\/4646"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/4227"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=4225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=4225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=4225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}