本文介绍了Netatmo Api-如果温度为X,则需要Hlep,否则为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Netatmo api在我的私有php页面中显示Netatmo的数据.
I use the Netatmo api to Show Data of my Netatmo in my Private php Page.
代码:
$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)
(will show the Temperature outside in C )
我想将回声显示为文本".因此,如果它的外部10 C显示文本:它的冷异常.
I want to show the echo as Text.So if its 10 C outside it shows text: its Cold outlide.
有人有主意吗?
推荐答案
您需要一个if
if($temp_aus<=10){
echo "Its cold outside";
}
else{
echo "Not its cold outside";
}
这篇关于Netatmo Api-如果温度为X,则需要Hlep,否则为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!