PHP Web Service

Post Reply
SpiderKenny
Posts: 2
Joined: Wed May 15, 2019 9:00 am

Hi everyone - my first post here!

I am trying to build a back-end webservice in PHP to control Supla devices.

I have a hosted linux server at my ISP and I have an Alexa Custom Skill hosted at Amazon.

The amazon skill is for an existing client of mine and already works very well. What it does is take amazon "intents" and convert them to various forms of communication with other devcies. For example it might post JSON to another webservice, or send MQTT messages to a broker. My hosted server also logs device inventories, service requests and so on in a MySQL database. This is all working well.

So what I can't get my head round is the control flow for Supla.
Here's what I have done:
I have looked at the PHP Supla Client at : https://github.com/SUPLA/api-client-php
I have created an OAuth Application under "My OAuth Apps" on Supla.
I have authorised that app in my account at Supla.
I have used "composer" to install the required components on my server.
(We can assume for the purposes of getting this working that my account is the only account) Account linking will come one I get my head round the control flow. I already do amazon account linking, so I should be able to cope with that.

Here's where I am stuck.
The instructions at https://github.com/SUPLA/api-client-php are missing. They stop at a very brief example: $client->getServerInfo();
What I'd like is an example of how my PHP Webservice should now work.
I've done this bit:

Code: Select all

<?php
$client = new \Supla\ApiClient\SuplaApiClient([
    'server' => 'svrX.supla.org',
    'clientId' => 'YOUR_CLIENT_ID',
    'secret' => 'YOUR_SECRET',
    'username' => 'YOUR_USERNAME',
    'password' => 'YOUR_PASSWORD',
]);
Where do I go from here to request an appropriate scope, and send control commands to a Supla device?
Does anyone have any example code for a back-end web service in PHP?
magx2
Posts: 351
Joined: Wed May 17, 2017 1:27 pm
Contact:

Check this site: https://app.swaggerhub.com/apis/supla/s ... ceChannels

On swagger hub you got API schema for Supla Cloud. Just click Export > Client SDK > PHP and you will have fully working PHP client for Supla
Java 4 Life :twisted:

API Java
GUI
Server Mock

SpiderKenny
Posts: 2
Joined: Wed May 15, 2019 9:00 am

Thanks for that - I will check it out.
Post Reply

Return to “Help”