Home Google Map Api How to get the latitude and longitude using curl php?

How to get the latitude and longitude using curl php?

by therichpost
0 comment
Php Preg_Match Pattern for Week Days Name

Hello, welcome to therichpost.com. In this post, I will tell you,  How to get the latitude and longitude using curl php? I personally like php ver much. PHP is the best web language. There are many cms and frameworks in PHP and WordPress is the best example. facebook also used PHPin it.

Today, we will get lat-long with the help of php curl function.


Here is the working code  and you have to enable curl on your system if it will not work:
  $details_url = "http://maps.googleapis.com/maps/api/geocode/json?address=ludhiana&sensor=false";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $details_url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  $geoloc = json_decode(curl_exec($ch), true);
  switch ($geoloc[‘status’]) {
    case 'ZERO_RESULTS':
      return 0;
    case 'OK':

 There are so many code in PHP and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.