Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get country name by ip address using google api

Tags:

php

google-api

I already have the google api key and want to know if it is possible to get country name of user(not share location) without any account from google Api

i think it is possible from user ip address but don't know how

like image 648
Shashi Kumar Avatar asked Sep 12 '25 22:09

Shashi Kumar


1 Answers

You can try like this, No need for Google Api

Check here : https://freegeoip.net

$geo_location = file_get_contents('http://freegeoip.net/json/'.$_SERVER['HTTP_CLIENT_IP']);
print_r($geo_location);

Hope this will help.

like image 75
Meera Tank Avatar answered Sep 15 '25 13:09

Meera Tank