dev-master 2018-09-26 05:48 UTC

This package is not auto-updated.

Last update: 2024-04-19 06:59:16 UTC


README

SONOS Control API implementation for PHP ( see https://developer.sonos.com/build/direct-control/ fore more information)

powered by hubware smart home factory

Please note: This library is work in progress. Some parts of the API are already implemented, some are pending. The authentication is using the new cloud-based redirect and callback urls. You need to have public reachable urls to get the necessary OAuth2 tokens.

License: MIT

Feel free to clone, improve and create pull requests. All code submitted to the project must be licensed under MIT license.

Preparation

Using it

In the tests/web directory are some files to get started

  • Copy __config.php.dist to __config.php and fill in all-ready known values (oauth client id + secret).
  • Copy the __api.php and __api_receiver.php to a public available url and configure them in the SONOS api console. They must be reachable when you call them in your browser! Localhost is not accepted by SONOS.
  • Run api_auth_1_create_access.php - login to the SONOS account using OAuth2 and be redirected to the __api.php script. Fill in the necessary information into your __config.php script.
  • Run api_auth_2_create_token.php - same here, you are redirected to __api_receiver.php and see in your browser the access and refresh token. Copy + paste into __config.php again.
  • Now you can play with your SONOS devices:
    • test_player.php to control some player + group devices over the SONOS cloud (quite fast)
    • test_callback.php to receive event callbacks by the SONOS cloud to your system (e.g. change volume on the player, or using the SONOS app); the latency of these callbacks is quite slow and really usable (5-10 seconds on average during the evaluation time in September 2018).

Hacking it

  • A lot of stuff is not yet finished. Please have a look at the src/ directory to see the code and improve it.
  • The cloud event callbacks are not implemented yet.
  • The OAuth2 registration process with the registered, public reachable callback urls are really a pain. If you can improve it, please do so. :-)
  • Create a pull request with clean code, added automated tests and logs that can be used to test against (without your private information).
  • Spread the word.