Netatmo API - 如果温度 X 需要 Hlep 然后



我使用 Netatmoapi 在我的私人 php 页面中显示我的 Netatmo 的数据。

法典:

$password="xxxx";
$username="xxxx";
// Daten vom Entwickler Account der Netatmo Seite
$app_id = "xxxxx";
$app_secret = "xxxxxx";
// ------------------------------
$token_url = "https://api.netatmo.net/oauth2/token";
$postdata = http_build_query(
array(
'grant_type' => "password",
'client_id' => $app_id,
'client_secret' => $app_secret,
'username' => $username,
'password' => $password
)
);
$opts = array('http' =>
array(
'method'  => 'POST',
'header'  => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context  = stream_context_create($opts);
$response = file_get_contents($token_url, false, $context);
$params = null;
$params = json_decode($response, true);
$url_devices = "https://api.netatmo.net/api/getstationsdata?access_token=".$params['access_token'];
$resulat_device = file_get_contents($url_devices);  
$array = json_decode($resulat_device,true);

结果:

echo $temp_aus;

(将显示 C 中的外部温度(

我想将回声显示为文本。 因此,如果它的 10 C 外部显示文本:它的冷外光。

有人有想法吗?

你需要一个if

if($temp_aus<=10){
echo "Its cold outside";
}
else{
echo "Not its cold outside";
}

最新更新