Using the API on a webpage

Hi guys,

For a project I’m doing for my company I’m using Xibo to display some information on 2 phones and a big screen connected to a desktop. This is all working fine. But now I want to create a simple webpage with a few buttons on it and when clicked the layout needs to be changed. So for example click button 1 and the layout changes to layout 1, press button 2, layout changes to layout 2.

I’m aware I need to use the API for this, so I tried some things in Postman and it al worked just fine. But the problem is getting it on a webpage. I tried using the code snippets from postman and convert these somehow to a working html page, but no success. Can anyone help me with this?

This is what I tried running (and unsurprisingly didn’t work):
http://pastebin.com/NWenEbR8

I have never worked with an API before and have basic HTML and CSS skills, none in Javascript, but definitely willing to learn hehe.

Kind regards,

Prox

1 Like

I don’t think you’re getting the access_token there, you would need to authenticate first then make the request.

Alternatively you could use wrappers from our PHP API library perhaps the examples folder there will help you out.
There are some examples there without using wrappers and calling access_token and then API call via clear Guzzle if that would be more suitable for you.

You could have that in php script and just trigger it by js linked to the button on your webpage.

Hi Peter,

Thank you for your quick reply. Here is my late response.

I tried messing around with the PHP-script you provided, but I can’t get it to work. Other than that I’m also trying to avoid having to install a PHP-server on the desktop, because it needs to be as dummy proof as possible.

Preferably I solely use javascript. I also don’t mind the possible security problems with storing the access token in a webpage because it will only be run on an local private network without any other users connected.

With kind regards,
prox