Thingsee Support

How to implement a simple custom cloud in php

Getting started with your own custom cloud requires a web server that will take in http POST requests.

If you have any experience with php, node, or any server side scripting, here's the short version:

  • Your device will send data to the custom cloud url as a POST request
  • Device metadata is in the request headers
  • Purpose and Task data will be in the request body
  • You need to reply with an HTTP/1.0 200 OK so the device will know the request went through. Otherwise it will wait for 30 seconds to timeout the connection.

An easy way to get started is to install php and use the built in simple server in php. In your terminal application,

  1. go to your project folder and
  2. type `php -S`

You now have a php and an http server running, and it'll send the HTTP 200 response automatically. (Note: you should only use the built in php server for testing, not for public use.)

Here's a simple example php script that will log everything coming from the device into a log.txt file:

  $logdata = "";

  //First get all metadata from headers and output in a readable format
  $headers = getallheaders();
  foreach ($headers as $name => $value) {
    $logdata .= "$name: $value\n";
  //Get request body, with all the data the device sent us
  $logdata .= @file_get_contents('php://input');

  //Add some line breaks and dashed line to separate request
  $logdata .= "\n----\n\n";
  //Add our data to the log file
  $logfile = fopen("log.txt","a");



Here's an example request that would be logged in the log.txt file, just as an example on what to expect:

connectorId: 1
connectorName: Thingsee Cloud
deviceAuthUuid: auth-id-goes-here
User-Agent: tsone/0.1
Accept: */*
Authorization: Bearer xyz.etc...
Connection: close
Content-Length: 133
Content-Type: application/json
Have more questions? Submit a request