Here you go - Very Simple Approach of others work, spark team included.
IMPORTANT NOTICE: Posting the PHP code to a non-secure server directory will allow someone else to control your Spark Core should they obtain your access_token number used in the CURL statement. I use Joomla and Apache Directory (Password) Protection when I run this code but, you can run it; test it and then change your access_token in Spark IDE later.
Spark IDE - Digital / Analog Write only:
coded starts next lines—>
/* Includes ------------------------------------------------------------------*/
#include “application.h”
/* Function prototypes -------------------------------------------------------*/
int tinkerDigitalWrite(String command);
/* This function is called once at start up ----------------------------------*/
void setup()
{
//Setup the Tinker application here
//Register all the Tinker functions
Spark.function(“digitalwrite”, tinkerDigitalWrite);
}
/* This function loops forever --------------------------------------------*/
void loop()
{
//This will run in a loop
}
/*******************************************************************************
- Function Name : tinkerDigitalWrite
- Description : Sets the specified pin HIGH or LOW
- Input : Pin and value
- Output : None.
- Return : 1 on success and a negative number on failure
*******************************************************************************/
int tinkerDigitalWrite(String command)
{
bool value = 0;
//convert ascii to integer
int pinNumber = command.charAt(1) - ‘0’;
//Sanity check to see if the pin numbers are within limits
if (pinNumber< 0 || pinNumber >7) return -1;
if(command.substring(3,7) == “HIGH”) value = 1;
else if(command.substring(3,6) == “LOW”) value = 0;
else return -2;
if(command.startsWith(“D”))
{
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, value);
return 1;
}
else if(command.startsWith(“A”))
{
pinMode(pinNumber+10, OUTPUT);
digitalWrite(pinNumber+10, value);
return 1;
}
else return -3;
}
<-----code ended above line
PHP File code next line---->
<?php
$ch = curl_init("https://api.spark.io/v1/devices/48ff6f065067555028091087/digitalwrite?access_token=78eb37d1eb1ad33610b907c329d49009dc033079");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "params=D7,HIGH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
$output = curl_exec($ch);
curl_close($ch);
$ch = curl_init("https://api.spark.io/v1/devices/48ff6f065067555028091087/digitalwrite?access_token=78eb37d1eb1ad33610b907c329d49009dc033079");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "params=D6,HIGH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
$output = curl_exec($ch);
curl_close($ch);
?>
<— Php file code ended above line
Name your php file something like D6and7_high.php and upload to a webpage/server and run it.
Let me know if I need to clarify more. No need to become a Android App builder when you can control all Analog / Digital pins via PHP & Curl.
Also feel free to PM me so not to high jack this thread (Not much support for PHP & Curl but, I will help best I can).
Bobby