I’ve done some research, and I understood that GET’s are meant for Spark.function()
and that POST’s are for Spark.variable(). But I just need to make sure someone did the GET, nothing else.
So. Is it possible to attach another function to a Spark.variable() call? Where should I be looking at? Any other suggested solution?
If possible, I wouldn’t like to directly use TCPServer… it doens’t seem like a reliable solution.
Actually, POST requests are for Spark.function() calls, and GET requests are to get Spark.variable(). Having cleared that, you could try using this code:
<html>
<head>
</head>
<body>
Function just executed.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
var deviceID = "Enter device ID here";
var accessToken = "Enter accestoken here";
var baseURL = "https://api.spark.io/v1/devices/";
function doMethod(func, data) {
var url = baseURL + deviceID + "/" + func;
$.ajax({
type: "POST",
url: url,
data: {
access_token: accessToken,
args: data
},
dataType: "json"
})
console.log("Sent POST request.");
};
doMethod("Enter function name", "optional: Enter function argument);
</script>
</body>
</html>
Place it on a host you can reach, and add it as a bookmark. As soon as you open it, the function will be called.
In this topic I’ve tried to explain why I think it’s not currently possible:
My solution above is a fairly simple one, as long as you can host the page somewhere. I believe github can do that for free
If you’re using the local cloud, then you should be able to edit the routing and make it do whatever you’d like it to do.