---
title: Varshphal API cURL example
description: "``` ```"
url: "https://jyotishapi.com/docs/varshphal-api-curl-example/"
updated: "2026-08-23"
category: Varshphal
---

# Varshphal API cURL example

```
<?php
$url = "https://webastrohost.com/v2/varshphal_ml/";

$userid = $_POST['clientid'];
$token = $_POST['apikey'];
$headers = array(
    'Method: GET',
    'Authorization: Basic '. base64_encode($userid.':'.$token)
);

$curl = curl_init();
$fields = array(

    'date' => $_POST["date"],
    'time' => $_POST["time"],
    'long' => $_POST["long"],
    'lat' => $_POST["lat"],
    'tzone' => $_POST["tzone"],
    'lang' => $_POST["lang"],
    'vsyear' => $_POST["vsyear"]

);
$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 {

  $data = json_decode($response);
?>
```
