Spark.variable() event

Hey guys,

I need to:

  1. change a LED state
  2. by clicking the bookmark in my home screen (iOS)

Well, clicking some bookmark means that I’ll be doing a HTTP GET to Spark

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:

		Function just executed.
		<script src=""></script>
			var deviceID    = "Enter device ID here";	
			var accessToken = "Enter accestoken here";	
			var baseURL = "";
			function doMethod(func, data) {			
			  var url = baseURL + deviceID + "/" + func;
				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);

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.

Let me know if you need any help.

Sorry for the mixup, you’re absolutely right. Thanks for the solution, but I was thinking on something more Spark-Cloud-local.

No servers, no document.ready stuff… Just a plain GET to Spark API that calls LED changing state.

Is that even possible?

Thanks again,


Not currently. You need to be able to make a POST request to call any spark functions.

Is this not possible with a Bookmark?

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 :slight_smile:
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.

Have you tried to store @Moors7 code as a .html file locally on your device an bookmark this local file?
With my MS device this works like a charm.

1 Like

I also store a local HTML file, but on Dropbox. That way I can get to it from home Mac, my work PC, and my iOS device.

Thanks guys! All those ideas are working fine!

1 Like