This object is in archive! 

reboot with http command?

Adrian Van Der Heijden shared this question 7 years ago
Need Answer

does anybody know, or can show me, how to implement a http command for a reboot of a zipatile/zipabox? I have tried many different versions using password, logins, etc but cant seem to get it right.

It would be nice to have this option that I can send from another controller on the same network, or NAS webserver etc to manually reboot a controller if necessary.

Any help would be greatly appreciated

Replies (2)

photo
1

Hi Adrian.


Here is a working PHP Script (not refactored; just quick and dirty).

Just replace the xxx (username, password, serial)


Put the script (copy it to Notepad++ or something and save it as filename.php) on a server and just call the url then the specified Zipatiel/Zipabox will reboot.


  1. <?php
  2. $username = 'xxx@xxx.xxx';
  3. $password = 'xxx;
  4. $serial = 'xxx';
  5. $nonce;
  6. $jsessionid;
  7. $token;
  8. $curl = curl_init();
  9. curl_setopt_array($curl, array(
  10. CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/user/init",
  11. CURLOPT_RETURNTRANSFER => true,
  12. CURLOPT_ENCODING => "",
  13. CURLOPT_MAXREDIRS => 10,
  14. CURLOPT_TIMEOUT => 30,
  15. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  16. CURLOPT_CUSTOMREQUEST => "GET",
  17. CURLOPT_HTTPHEADER => array(
  18. ),
  19. ));
  20. $response = curl_exec($curl);
  21. $err = curl_error($curl);
  22. curl_close($curl);
  23. if ($err)
  24. {
  25. echo "cURL Error #:" . $err;
  26. }
  27. else
  28. {
  29. $json = json_decode($response, true);
  30. $nonce = $json['nonce'];
  31. $jsessionid = $json['jsessionid'];
  32. $password = sha1($password);
  33. $token = $nonce . $password;
  34. $token = sha1($token);
  35. }
  36. $curl = curl_init();
  37. curl_setopt_array($curl, array(
  38. CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/user/login?token=$token&username=$username",
  39. CURLOPT_RETURNTRANSFER => true,
  40. CURLOPT_ENCODING => "",
  41. CURLOPT_MAXREDIRS => 10,
  42. CURLOPT_TIMEOUT => 30,
  43. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  44. CURLOPT_CUSTOMREQUEST => "GET",
  45. CURLOPT_HTTPHEADER => array(
  46. "accept: application/json",
  47. "cookie: JSESSIONID = $jsessionid;"
  48. ),
  49. ));
  50. $response = curl_exec($curl);
  51. $err = curl_error($curl);
  52. curl_close($curl);
  53. if ($err)
  54. {
  55. echo "cURL Error #:" . $err;
  56. }
  57. $curl = curl_init();
  58. curl_setopt_array($curl, array(
  59. CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/box/reboot/$serial",
  60. CURLOPT_RETURNTRANSFER => true,
  61. CURLOPT_ENCODING => "",
  62. CURLOPT_MAXREDIRS => 10,
  63. CURLOPT_TIMEOUT => 30,
  64. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  65. CURLOPT_CUSTOMREQUEST => "GET",
  66. CURLOPT_HTTPHEADER => array(
  67. "accept: application/json",
  68. "cookie: JSESSIONID = $jsessionid;"
  69. ),
  70. ));
  71. $response = curl_exec($curl);
  72. $err = curl_error($curl);
  73. curl_close($curl);
  74. if ($err)
  75. {
  76. echo "cURL Error #:" . $err;
  77. }
  78. else
  79. {
  80. echo 'success';
  81. }
  82. ?>

photo
1

Thanks Chris, i'll check it out over the weekend. Much appreciated. Just seems overly complicated for what it should be.

photo
2

Hi Adrian.

It is not too complicated.

A big part of it is alway the same as it is just for authentification. So this part is reusable for everything you want to do with the API. The rest is more or less a copy paste exercise with small adjustments.

It would be much easier if Zipabox/Zipatile could handle http-response or authentification would work with API Key instead of Token. Then you could do this with a simple rule.

photo
photo
1

I really need to get a NAS / server...

photo
1

Dear Alberto.


I would rather suggest a Raspberry with a Flirc. It is much cheaper and you can also start activities with remote control like Harmony.

photo
Leave a Comment
 
Attach a file