Get values from Yún web server

Hello,
Before 2 day I bought the Yun and need some push from your experience.
I have the temperature web server running and showing the values from A0 and A1.
Forwarded the 80 port to the Yun in order to see the values from the Internet.
I also have a Debian server running somewhere in the word.

My project is to collect info from my Yun I have at home to a central Debian server and there display it with beauty and CSS3 and other fancy stuff.

So my question is:
How can I collect the values which are displayed on the Yun server to my Debian server?

Thank you.

Your debian server can use cURL to get http://YourHomeIpOrDinamicDns/data/get/A0 and http://YourHomeIpOrDinamicDns/data/get/A1

I did it with some php

<?php
// Open the arduino sensor1 and read
$read = fopen("http://externalIP/arduino/sensor1", "r")  
or die("Error");    

$contents = fread($read,2); // Read the bytes
$contents = htmlentities($contents);

// Display the contents
echo "<pre>$contents</pre>";
?>

does fopen works also if you set the REST api password protected ?

No, it wasn't
I have to find a way to pass the password but I left it for another day.
My priority is to make it work and then secure it

curl does it!

<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://[u]YOUR_DNS_or_IP[/u]/[u]YOUR_PATH[/u]"); curl_setopt($ch, CURLOPT_USERPWD, "[u]YOUR_USER[/u]**:**[u]YOUR_PASSWORD[/u]"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; ?>

If you're sending user & pwd over the network, you should use https, not plain http

of course.. i used this code on localhost (before you said to me to use the PHP library!).. thanks Federico for the tips

5a2v0:
Your debian server can use cURL to get http://YourHomeIpOrDinamicDns/data/get/A0 and http://YourHomeIpOrDinamicDns/data/get/A1

Could you explain me how to use it?
When I try it I get this

{"key":"0","response":"get"}

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

Thank you for your time. This was very helpful for me.