Quantcast
Channel: IP-Phone-Forum
Viewing all articles
Browse latest Browse all 15636

[Sammlung] SensorAndSwitch: Pseudoscript: Wetter

$
0
0
thx to JL3:

Zeigt das aktuelle Wetter und die temperatur zu den in der Konfiguration hinterlegten Daten an

Erstellung/Installation: Datei mit unten stehenden Namen und Inhalt im SaS Webverzeichnis erstellen.

Dateiname: pseudowetter.php

PHP-Code:

<?php

    
/*
        +---------------------------------------------------------------------+
        |                                                                     |
        |   SensorAndSwitch Automation Pro                                    |
        |   PseudoGerä-Script                                               |
        |   ===============================================================   |
        |   -> Wetter                                                         |
        |      openweathermap.org                                             |
        |      Informationen von obiger Homepage fü Ort, der             |
        |      anhand der in den Einstellungen eingelesenen Läen- und       |
        |      Breitengraden ermittelt wurde.                                 |
        |                                                                     |
        +---------------------------------------------------------------------+
    */

    
error_reporting(0);
    include 
"include/includedateien.php";
    include 
"include/includefunctions.php";
    include 
"include/includeconf.php";
    include 
"include/includeconfig.php";
    include 
"include/includedefine.php";
    
$url="http://api.openweathermap.org/data/2.5/weather?lat=".BREITENGRAD."&lon=".LAENGENGRAD."&mode=xml&units=metric&lang=de";
    
$ch curl_init();
    
$timeout 5;
    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_SSL_VERIFYHOST,false);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEER,false);
    
curl_setopt($chCURLOPT_MAXREDIRS10);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_CONNECTTIMEOUT$timeout);
    
$Status curl_exec($ch);
    
curl_close($ch);
    if (
$Status) {
        
$Cont=simplexml_load_string($Status);
        
$Temp=number_format(sprintf('%.2f',$Cont->temperature->attributes()->value),2,",",".");
        
$Stadt=$Cont->city->attributes()->name;
        
$Symbol='<img src="http://openweathermap.org/img/w/'.$Cont->weather->attributes()->icon.'.png">';
        
$Wetter=$Cont->weather->attributes()->value;
        echo 
"T#".sprintf('%.2f',$Cont->temperature->attributes()->value)."#P#".'<div style="font-size:14px;text-align:left;width:310px;position:relative;top:-20px;">'.$Symbol.'</div><div style="font-size:14px;text-align:left;width:310px;position:relative;top:-30px;left:0px;">'.$Wetter.'</div><div  style="text-align:right;width:310px;position:relative;top:-65px;">'.'Temperatur: '.$Temp.'°C</div>'."*HTML#";
    }
    else {
        echo 
"T##P##E##";
    }
    exit;
?>


Viewing all articles
Browse latest Browse all 15636

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>