Login
Example on how to Login
Request data
Name | Type | Description |
---|---|---|
String | Email is part of initial set of credentials. | |
password | String | Password is part of initial set of credentials. |
This sample code is written in PHP:
$url = 'https://api.wthvillas.com/api/v1/login';
$data = array(
'email' => "apiuser@wthvillas.com",
'password' => "myvillapassword"
);
$data_string = json_encode($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST,count($data));
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$response = curl_exec($curl);
curl_close($curl);
$returnData = json_decode($response, true);
print_r($returnData);
Response example data
{
"response": "success",
"token": "OWQzZDNlODYyZDciLCJpYuRYBBoWoDOy47k-B3ZYVluQawcOOjIaJoBRzVZK1jWaX9flgxKdBwV5J8cCNNyRLyHRuwHe-LI"
}