api_username site api_password 12345 api_url http 85 117 243 84 send_d

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$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);