Guest User

Untitled

a guest
Mar 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2. $device = 'ruth_1';
  3. $user = 'admin';
  4. $resource = 'led';
  5. $authorization = 'auth key from api explorer';
  6. $state = ($_GET['state']=='true')?true:false;
  7.  
  8. $url = "host/v2/users/{$user}/devices/{$device}/{$resource}?authorization={$authorization}";
  9.  
  10. $data = array(
  11. 'in' => $state
  12. );
  13.  
  14. $options = array(
  15. 'http' => array(
  16. 'method'  => 'POST',
  17. 'content' => json_encode( $data ),
  18. 'header'=>  "Content-Type: application/json\r\n" .
  19.             "Accept: application/json\r\n"
  20. )
  21. );
  22.  
  23. $context  = stream_context_create( $options );
  24. $result = file_get_contents( $url, false, $context );
  25. $response = json_decode( $result );
  26. ?>
Add Comment
Please, Sign In to add comment