Categories

Monday, April 22, 2024
#919814419350 therichposts@gmail.com
Google Map ApiPhp

How to get the latitude and longitude using curl php?

get the latitude and longitude using curl php

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.

google-lat-long

Here is the working code  and you have to enable curl on your system if it will not work:
<?php
  $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;
      break;
    case 'OK':
      print_r($geoloc['results'][0]['geometry']['location']);
      break;
  }
             ?>

 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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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