The url "https://your.arduino.ip/data/get/xxx" will get a string that contain the variable "xxx" that you must set in your void loop()...example:
#include <Bridge.h>
int pin = A0;
int pinValue = 0;
void setup() {
Bridge.begin();
}
void loop() {
pinValue = analogRead(pin);
Bridge.put("A0", String(pinValue));
//note this "A0" is the variable's name passed to linux which you will get with curl
delay(1000); //do it all every 1 second
}
with:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://YOUR_DNS_or_ARDUINO_IP/data/get/A0");
curl_setopt($ch, CURLOPT_USERPWD, "YOUR_USER:YOUR_PASSWORD");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
The php output will be something like:
{"value":"7","key":"A0","response":"get"}
Where A0 is the variable's name and 7 its value.
In your php page, after the: curl_close($ch);
you can work this output with:
$result = json_decode($output, true);
$A0 = $result[value]['A0']; //will be 7
If you want to get more than one variables values, you can get url "https://your.arduino.ip/data/get/" which give to you a Json string with all variables and their values , like this: {"value":{"A0":"7","A1":"53","A2":"4","A3":"0","A4":"10","A5":"1004"},"response":"get"}
this string give to you all values with this code:
$result = json_decode($output, true);
$A0 = $result[value]['A0']; //will be 7
$A1 = $result[value]['A1']; //will be 53
$A2 = $result[value]['A2']; //will be 4
$A3 = $result[value]['A3']; //will be 0
$A4 = $result[value]['A4']; //will be 10
$A5 = $result[value]['A5']; //will be 1004