-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathclient-connect.php
53 lines (39 loc) · 1.11 KB
/
client-connect.php
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
46
47
48
49
50
51
52
53
<?php
if (!function_exists('curl_init')) {
die('Curl module not installed!' . PHP_EOL);
}
$route = '/ping';
//$route = '/test/4';
//$route = '/doesntexist';
//$route = '/skip/auth';
if (isset($argv[1])) {
$host = 'http://' . $argv[1] . $route;
} else {
$host = "http://helio.api" . $route.".xml?token=oWMhwXXmSnSR5y3Xj9ljGzLmgu5q8I0JFtQuSrxg";
}
//$headers = ['ACCESS_TOKEN: cbx4S1QCBOmZHRan0z4jHkTWiqLKNeLrMMSFW68M'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_POST, FALSE);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
$result = curl_exec($ch);
if ($result === FALSE) {
echo "Curl Error: " . curl_error($ch);
} else {
echo PHP_EOL;
echo "Request: " . PHP_EOL;
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
echo PHP_EOL;
echo "Response:" . PHP_EOL;
echo $result;
echo PHP_EOL;
}
curl_close($ch);
function buildMessage($time, $id, array $data) {
return $time . $id . implode($data);
}
?>