Feedback on PHP Proxy remote control implementation

Hi,

I’ve created a PHP Proxy to hide the access_token and the deviceID online. I’ve started with the Simple Spark PHP Proxy from @wgbartley , however to fully understand it I’ve reworked the code.

I decided to also hide the deviceID, so you will give less information to the end-user.

I noticed that the speed of a request is slower (about 200-300ms without proxy and around 600-700ms with). I’m curious if someone has idea’s to speed it up. I measured on my local system the same speeds. My webserver is based in the Netherlands, so maybe from the US the request speed is even slower.

I’m also curious about the security and if someone sees some improvements that I can make.

I’ve put a temporary demo online (mainly because I won’t keep the Photon with the code online). I noticed the sliders don’t work on mobile.

https://kasperkamperman.com/temp_api_demo/

The proxy api code:

I’m especially wondering if you can keep the cURL connection open (that might speed thinks up I assume). I think now every request opens and closes the connection with the API. I don’t know how that happens internally in the Particle API. I’ve found some cURL async tools to run multiple requests at once, however I think that doesn’t apply here, because I don’t run requests from that PHP page, but I run them from JavaScript.

1 Like