You are reading a single comment by @Ollie and its replies. Click here to read the full conversation.
  • For receiving webhooks without messing with firewalls etc use a public webserver to receive the request then poll that server for the data? My example is PHP - maybe be better in Go or Node.js, depending on how realtime you needed the thing to feel?

    <?php 
    const PRIVATE_KEY = "my_private_key";
    // Authenticate
    if(!@$_REQUEST["key"] || $_REQUEST["key"] !== PRIVATE_KEY) {
    	header('HTTP/1.0 401 Unauthorized');
    	echo 'HTTP/1.0 401 Unauthorized';
    	die();
    }	
    // Handle request
    if($_POST) {
    	// Update data and write to a file - validation maybe - but it should be data you expect
    	file_put_contents('data.espruino', json_encode($_POST));	
    } else {	
    	// Get data from file, set headers and display
    	header('Content-Type: application/json');
    	echo file_get_contents('data.espruino');
    }
    
About

Avatar for Ollie @Ollie started