-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
50 lines (43 loc) · 1.91 KB
/
Copy pathexample.php
File metadata and controls
50 lines (43 loc) · 1.91 KB
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
<?php
require_once 'common.php';
if (isset($_GET['clear'])) {
session_destroy();
header('location:example.php');
exit();
}
if (!isset($_SESSION['accessToken'])) {
?>We have no access token, <a href="getRequestToken.php">connect us</a><?php
exit();
}
?>
<p>We have access!</p>
<p>
In your system, store these values to do requests for this user:<br>
Token: <?php echo $_SESSION['accessToken']; ?><br>
Secret: <?php echo $_SESSION['accessTokenSecret']; ?>
</p>
<p><a href="example.php?clear">Clear the token and restart</a></p>
<p><a href="example.php?listDevices">List users devices</a></p>
<?php
if (isset($_GET['listDevices'])) {
$consumer = new HTTP_OAuth_Consumer(constant('PUBLIC_KEY'), constant('PRIVATE_KEY'), $_SESSION['accessToken'], $_SESSION['accessTokenSecret']);
$params = array(
'supportedMethods' => constant('TELLSTICK_TURNON') | constant('TELLSTICK_TURNOFF'),
);
$response = $consumer->sendRequest(constant('REQUEST_URI').'/devices/list', $params, 'GET');
echo '<pre>';
echo( htmlentities($response->getBody()));
}
?><p><a href="example.php?listClients">List users clients</a></p><?php
if (isset($_GET['listClients'])) {
$consumer = new HTTP_OAuth_Consumer(constant('PUBLIC_KEY'), constant('PRIVATE_KEY'), $_SESSION['accessToken'], $_SESSION['accessTokenSecret']);
echo constant('PUBLIC_KEY') . '<br/>';
echo constant('PRIVATE_KEY') . '<br/>';
echo $_SESSION['accessToken'] . '<br/>';
echo $_SESSION['accessTokenSecret'] . '<br/>';
echo constant('REQUEST_URI').'/clients/list' . '<br/>';
$params = array();
$response = $consumer->sendRequest(constant('REQUEST_URI').'/clients/list', $params, 'GET');
echo '<pre>';
echo( htmlentities($response->getBody()));
}