$api_username = 'site';
$api_password = '12345';
$api_url = 'http://85.117.243.84';
$send_data = array('login' => $api_username, 'password' => $api_password);
$data_string = json_encode($send_data);
$dump = true;
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $api_url . '/uaz_work/hs/Site/auth');
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $api_username . ":" . $api_password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,
CURLOPT_POSTFIELDS,
$data_string
);
// $output contains the output string
$output = curl_exec($ch);
var_dump($data_string);
var_dump($output);
if($dump){
die($output);
}
// close curl resource to free up system resources
curl_close($ch);
$response = json_decode($output, true);