Simple digitalwrite form & curl in .php

Not sure if using php really makes sense… wanted to quickly try controlling the core from a web page/server. Bit messy but hope it is useful to someone else.

Your core should be running tinker when you receive it, so no need to change anything on the core itself. You just need to connect it to the web, [breathing cyan].

You will need to know and change two variables:
a) $my_access_token ; this is your access token (find this in the build tool under SETTINGS)
b) $my_device ; your cores device id (find this in the build tool under CORES)
/** i changed these variables to text box in the form

This is a basic form that can control the little blue led on/off which is located on D7, just ftp it to your web server. Really consists of 3 parts:

  1. a form to set the D7 bit state
  2. building the url from variables
  3. the cURL function

example here: .php digitalwrite
code here: github

4 Likes

This worked great, my first .php controlling Spark Core.

Any other examples, for more inputs, perhaps using a HIGH button, rather than radio button.
Maybe an example of reading values.

Awesome !!

2 Likes

Thank you! Just got my Spark a couple of days ago, having a lot of fun but wasn’t able to get typed curl commands to work (access token issues - not sure why) but your script worked great - thanks again!

-tom

2 Likes

Thanks for the php code,

Can you tell me how I can get a reading with php code? for example the reading of the temperature example. I want it to display it in an ios app.

if I can get the temperature reading as and display it as a nsinteger that would be great.

Thank you for the help.

Hi @bibomain,

I did a quick search and found a tutorial on making an http Get request and parsing JSON in iOS here: