Following PHP cURL code can be used to connect and get the response of Panchang API.
<?php
$url = "https://panchang.jyotishapi.com/";
$userid = 'xxxxx'; Your user id, will be sent to you through mail
$token = 'xxxxxxxxxxxxxxxxx'; your api key,will be sent to you through mail
$headers = array(
'Method: GET',
'Authorization: Basic '. base64_encode($userid.':'.$token)
);
$curl = curl_init();
$fields = array(
'date' => $_POST["date"],
'long' => $_POST["long"],
'lat' => $_POST["lat"],
'tzone' => $_POST["tzone"]
);
$fields_string = http_build_query($fields);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
//echo $response;
$data = json_decode($response);
?>