title: google api to get user city from IP
body: <p>Currently I am using <code>ipinfo</code> api to get the city of users who come on my page. But it fails for many IPs and does not show city.</p>
  
  <p>Is there any direct google API which gives city from user's IP?</p>
  
  <p>I show google apis but it was giving city from langitude and lattitude. I dont have these values, I want to get direct city from IP.</p>
  
  <pre><code>$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
      $citybyip= $details-&gt;city;
  </code></pre>