Letzte News vom Forum im Webfront anzeigen

Hi zusammen,

habe mal wieder was im Forum gefunden und für mich erfolgreich recycelt. Das Original-Script stammt aus diesem Thread https://www.symcon.de/forum/threads/9235-Atom-1-0-RSS-als-Popup-WebFront-ausgeben?highlight=news+webfront

Das habe ich umgebaut um die letzten News aus dem Forum im Webfront anzuzeigen. Hier das Ergebnis:

Das Script ist noch etwas „unsauber“, aber bei Bedarf gerne melden.

Ciao Pitti

Hi Pitti,
ich hätte Interesse an dem Skript…

Beste Grüße
Kai

Hi Kai,

gerne doch :smiley:


<?
// Individuellen Parameter anhängen um Cacheing zu vermeiden
$hit = date("YmdHi", time()); 
$url = 'https://www.symcon.de/forum/external.php?type=rss2&lastpost=1&cache='.$hit;
$xml = simplexml_load_file($url);
//print_r($xml);
setlocale(LC_TIME, 'deu_deu');
date_default_timezone_set('Europe/Berlin');
$news_count = count($xml->channel->item); // Anzahl der im RSS Feed vorhandenen News 
// Letztes Update und Lebenszeit (Time To Live)
$news_last = $xml->channel->lastBuildDate;
$news_ttl = $xml->channel->ttl;
#echo $news_count;
$news_want = 100; // Anzahl der gewünschten, anzuzeigenden News 

// Wenn Anzahl der vorhandenen News kleiner der gewünschten News ... 
if($news_count < $news_want) {
	// dann Anzahl der vorhandene News gleich den gewünschten News. 
	$news_want = $news_count;
} 

// HTML Styles, individuell anpasspar
$style = "";
$style = $style.'<style type="text/css">';
$style = $style.'table {width:100%;border-collapse: collapse;}';
$style = $style.'td.rss {vertical-align: top;text-align:left;padding:5px 10px 5px 10px;border: 1px solid rgba(255, 255, 255, 0.2);}';
$style = $style.'tr:nth-child(even) {background-color: rgba(0, 0, 0, 0.3);}';
$style = $style.'a.rlink { color: rgba(128, 128, 0, 1.0); text-decoration:none; font-weight:bold;}';
$style = $style.'div.rtitle { float:left;}';
$style = $style.'div.rctor { clear:both; color: rgba(192, 192, 192, 0.7); font-style:italic; font-size: small; padding: 2px 0px 5px 0px;}';
$style = $style.'div.rdate { float:right; color: rgba(192, 192, 192, 0.5); font-size: small;}';
$style = $style.'div.rdesc { font-size: smaller; width:90%;}';
$style = $style.'</style>';


// Feed in HTML Table umwandeln
$feed  = $style.'<table>'; 
//Hier werden die News, in der gewünschten Anzahl, eingelesen und formartiert. 
for($i=0; $i<$news_want; $i++) { 
	$item = $xml->channel->item[$i]; 
	$news = $item->title; 
	$news = text_formatierung($news); 
	$desc = text_formatierung($item->description);
	$link = $item->link; 
	$date = $item->pubDate; 
	$date = date_formatierung($date); 
	$cat  = $item->category;
	$ctor = $item->children('http://purl.org/dc/elements/1.1/')->creator;
	// build html entry
	$feed .= '<tr><td class="rss">';
	$feed .= '<div class="rtitle"><a class="rlink" href="'.$link.'" target="_blank">'.$news.'</a></div>';
	$feed .= '<div class="rdate">'.$date.'</div>';
	$feed .= '<div class="rctor">'.$ctor.' - '.$cat.'</div>'; 
	$feed .= '<div class="rdesc">'.$desc.'</div>';
	$feed .= '</td></tr>'; 
} 
// Fertig
$feed .= '</table>';

// Fürs Webfront in Variable schreiben (String-Variable mit ~HTMLBox Profil) 
SetValue(24053 /*[Steuerung\Internet\Feed Reader\Abruf von forum.ipsymcon.de\Feed]*/, $feed);

// Funktion zur Datums Formatanpassung, kann individuell verändert werden. 
function date_formatierung($date) { 
	$heute = time();
	$heute = date("d.m.Y" , $heute);
	$gestern = date("d.m.Y", strtotime("-1 days"));
	
	$publ = date("d.m.Y", strtotime($date)); 

	if($heute == $publ) {
		$publ = 'Heute, '.strftime('%d %B %Y %H:%M:%S', strtotime($date));
	}
	else if($gestern == $publ) {
		$publ = 'Gestern, '.strftime('%d %B %Y %H:%M:%S', strtotime($date));
	}
	else {
		$publ = strftime('%A, %d %B %Y %H:%M:%S', strtotime($date));
	}
	
	return $publ; 
} 

// Funktion zur News Formatierung , kann individuell erweitert werden. 
function text_formatierung($news){ 
	$news=strip_tags($news); 
	$news=html_entity_decode($news); 
	$news=str_replace("         ", " ", $news); 
	$news=str_replace("ö", "ö", $news); 
	$news=str_replace("Ãœ", "Ü", $news); 
	$news=str_replace("ü", "ü", $news); 
	$news=str_replace("ä", "ä", $news); 
	$news=str_replace("ß", "ß", $news); 
	$news=str_replace("&ndash;", "-", $news); 
	$news=str_replace('&#039;', "`", $news); 
	$news=str_replace("&", "&", $news); 
	$news=str_replace("Ö", "Ö", $news); 
	$news=str_replace("„", "", $news); 
	$news=str_replace("“", "", $news); 
	$news=str_replace("–", "-", $news); 
	$news=str_replace("„", "", $news); 
	$news=str_replace("“", "", $news); 
	$news=str_replace("„", "", $news); 
	$news=str_replace("–", "-", $news); 
	$news=str_replace("–", "-", $news); 
	$news=preg_replace("/\r|
/s", "", $news); 
	return $news; 
} 
?&gt;

Viel Spaß
Pitti

Nett, so könnte man seine bevorzugten Foren loggen und hat einen einfachen schnelle Überblick was gerade geht, ohne dass man irgend eine (blöde) App braucht oder die einzelnen Websites abgrast.

Verbeserungsvorschlag:
Wenn man auf einen Beitrag draufklickt, wird der Link zum Beitrag im Browser geöffnet, dann kann man auch gleich antworten.

Wieder so ne Dummie-Frage:
Wie aktualisiert sich das? Ich habe an das Script ein Ereignis angehängt zur Aktualierung alle x Sekunden. Das wird auch hübsch ausgeführt und die Variable aktualisert sich auch, aber im Webfront ist davon nichts zu sehen, da wird tapfer weiter der Stand angezeigt, als ich das Script erstmalig ausgeführt hatte.

Ist doch schon umgesetzt :wink: Die Überschift (Titel) ist verlinkt!

Die TTL ist 60 min, d.h. aller Stunde kommt was neues - also den Timer (so habe ich es gemacht) auf eine Stunde gestellt.

Ciao Pitti

ok, ich hatte auf die Nachricht getippt, nicht auf die Überschrift - kaum macht man es richt, gleich gehts. Danke.
Das mit der TTL hab ich nicht kappiert. Im Script-Code finde ich dazu nix. Bräuchte ich also im Prinzip gar kein Ereignis-Timer? Kann man den TTL verkürzen?

Nein, das Forumsystem (vBulletin) generiert aller 60 min (so ist es eingestellt) den Feed neu.

Im Script findest Du 2 Variablen ($news_last & $news_ttl), welche den letzten Generierungszeitpunkt und die Lebenszeit beinhalten (derzeit nicht verwendet).
Mit der Info könnte man natürlich genau berechnen wann man das nächste Mal den Feed abholen sollte, aber dazu bin ich am WE nicht gekommen. Müsste man halt bauen :wink:

Deswegen hatte ich einfach einen 1h Timer angelegt :cool:

Ciao Pitti

ok. Der News-Feed unterscheidet sich aber irgendwie etwas von dem „Ticker“ oben im Board. Der Ticker läßsst sich aktualisieren und er zeigt auch einige Beiträge mehr an. Ich habe das Muster nicht ganz rausgekriegt, aber es scheint so zu sein, dass hier im Ticker die Beta-Beiträge enthalten sind, in dem Stream aber nicht. Wäre halbwegs logisch, weil man sich für den Stream ja nicht angemeldet hat.

Im Prinzip reicht natürlich ein Aktualisierung alle Stunde. Aber ein „Aktualisieren-Button“ wäre doch schön.

Vielen Dank Pitti

Okay, vielleicht habe ich mich unverständlich ausgedrückt. Das System erzeugt aller Stunde ein Snapshot von den letzten Posts im Forum. Alle Posts die bis zur nächsten Generierung (+1h) anfallen kommen dann beim nächsten mal mit.

Das ist kein Live-Ticker oder so!!! Deshalb die TTL, welche auf 1 Stunde steht - wenn man die z.B. auf eine Minute stellt ist es fast ein Live-Ticker. Aber dann beschäftigt sich das System mehr mit sich selber als die User im Forum zu bedienen. Die haben Vorrang vor Extern :wink:

Ciao Pitti

Nur zur Info:
Die URL die pitti verwendet…

https://www.symcon.de/forum/external.php?type=rss2&lastpost=1

…kann in jeden RSS Reader eingetragen werden. Auch z.B. in einem RSS-Browser-Plugin, Outlook oder auch direkt in meinem RSS-Modul ausgewählt werden [emoji4]

Auch wenn es eigentlich kein echter RSS Feed ist, die „Syntax“ ist identisch [emoji4]

Grüße,
Chris

Klar, so geht es auch. Hatte Dein Modul nicht auf dem Radar :slight_smile:

Im Script findest Du 2 Variablen ($news_last & $news_ttl), welche den letzten Generierungszeitpunkt und die Lebenszeit beinhalten (derzeit nicht verwendet).
Mit der Info könnte man natürlich genau berechnen wann man das nächste Mal den Feed abholen sollte, aber dazu bin ich am WE nicht gekommen. Müsste man halt bauen :wink:

Das Problem habe ich jetzt über folgende Funktion gelöst:


////////////////////////////////////////////////////////////////////////////////
// id:
//	Int - Parent 
// name:
//	String - Event name
// type:
//	0 => Legt ein “ausgelöstes” Ereignis an
//	1 => Legt ein “zyklisches” Ereignis an
//	2 => Legt ein “Wochenplan” Ereignis an
// time:
//     Zeit für nächsten Aufruf
function CreateEventByName($id, $name, $type, $time) 
{ 
	if($time < time()) {
		return -1;
	}

	$eid = @IPS_GetEventIDByName($name, $id); 
	if($eid===false) { 
	  $eid = IPS_CreateEvent($type); 
	  IPS_SetParent($eid, $id); 
	  IPS_SetName($eid, $name); 
	} 

	// einmaliges Event
    IPS_SetEventCyclic($eid, 1, 0, 0, 0, 0, 0); 
	IPS_SetEventCyclicDateFrom($eid, (int)date('j',$time), (int)date('n', $time),  (int)date('Y', $time)); 
	IPS_SetEventCyclicDateTo($eid, 0, 0, 0); 
	IPS_SetEventCyclicTimeFrom($eid, (int)date("H", $time), (int)date("i", $time), (int)date("s", $time)); 
	IPS_SetEventCyclicTimeTo($eid, 0, 0, 0);
	IPS_SetEventActive($eid, true); 
	return $eid; 
}


Hinter dem SetValue(xxxx, $feed); Befehl dann einfach folgendes hinzufügen:


// Fürs Webfront in Variable schreiben (String-Variable mit ~HTMLBox Profil) 
SetValue(12345, $feed);

// Neuen Aktualisierungstimer erzeugen (+10 min um sicher zu gehen)
$update = strtotime($news_last) + (($news_ttl+10)*60);
CreateEventByName($_IPS['SELF'], "Update", 1, $update); 

Läuft bis jetzt einwandfrei!

Ciao Pitti

Hmm wo ist das PHP Eingabe Zeichen hin?
Danke Handzahmer, hier noch die Zeilennummern als Bild
[quote="<?
// Individuellen Parameter anhängen um Cacheing zu vermeiden
$hit = date(„YmdHi“, time());
$url = ‚https://community.symcon.de/latest.rss‘.$hit;
$xml = simplexml_load_file($url);
//print_r($xml);
setlocale(LC_TIME, ‚deu_deu‘);
date_default_timezone_set(‚Europe/Berlin‘);
$news_count = count($xml->channel->item); // Anzahl der im RSS Feed vorhandenen News
// Letztes Update und Lebenszeit (Time To Live)
$news_last = $xml->channel->lastBuildDate;
$news_ttl = $xml->channel->ttl;
#echo $news_count;
$news_want = 100; // Anzahl der gewünschten, anzuzeigenden News

[/quote]
Diese Zeilen werfen diese Fehler:
[quote=
Warning: simplexml_load_file(https://community.symcon.de/latest.rss202102051752): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in C:\ProgramData\Symcon\scripts\44559.ips.php on line 5

Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://community.symcon.de/latest.rss202102051752" in C:\ProgramData\Symcon\scripts\44559.ips.php on line 5

Warning: setlocale() has been disabled for security reasons in C:\ProgramData\Symcon\scripts\44559.ips.php on line 7

Notice: Trying to get property ‚channel‘ of non-object in C:\ProgramData\Symcon\scripts\44559.ips.php on line 9

Notice: Trying to get property ‚item‘ of non-object in C:\ProgramData\Symcon\scripts\44559.ips.php on line 9

Warning: count(): Parameter must be an array or an object that implements Countable in C:\ProgramData\Symcon\scripts\44559.ips.php on line 9

Notice: Trying to get property ‚channel‘ of non-object in C:\ProgramData\Symcon\scripts\44559.ips.php on line 11

Notice: Trying to get property ‚lastBuildDate‘ of non-object in C:\ProgramData\Symcon\scripts\44559.ips.php on line 11

Notice: Trying to get property ‚channel‘ of non-object in C:\ProgramData\Symcon\scripts\44559.ips.php on line 12

Notice: Trying to get property ‚ttl‘ of non-object in C:\ProgramData\Symcon\scripts\44559.ips.php on line 12
[/quote]

Dort:


Michael

Hallo Helmut,

da ich mir nicht sicher bin ob Du das aktuellste Script hast oder ich es up-to-date im Forum gehalten habe und gestern 1,2 kleine Dinge verbessert habe … hier nochmal mein aktuelles Script:

<?php
################################################################################
# Script:   Online.Feeds.ips.php
# Version:  2.1.20210203
# Author:   Heiko Wilknitz (@pitti)
#
# Abruf von Newsfeeds aus dem Internet 
#
# ------------------------------- Installation ---------------------------------
#
# Dieses Skript richtet automatisch alle nötigen Objekte bei manueller
# Ausführung auf der Console ein.
#  
# --------------------------------- Changelog ----------------------------------
#
# v2.1.20210203 - Umstellung auf Discourse
# v2.0.20180310 - Cache Parameter
# ----------------------------- Konfigruration ---------------------------------
#
# Array einfach mit den gewünschten Newsfeeds erweitern!
$feeds = [
    'IPSymcon' => 'https://community.symcon.de/latest.rss',
];
#
# Update Profil 
$update = [
  [1, '►', '', 0x008000],
];
#
################################################################################

switch ($_IPS['SENDER']) {
    // INSTALL & INITIALIZE 
    case 'Execute':
        Install($feeds, $update);
        break;
    // AKTION VIA TIMER 
    case 'TimerEvent':
        $name = strstr(IPS_GetName($_IPS['EVENT']), 'Update', true);
        foreach($feeds as $key => $value) {
            if($name == $key) {
                FeedReader($key, $value);
            }
        }
        break;
    // AKTION VIA WEBFRONT
    case 'WebFront':
        // Update
        SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);
        foreach($feeds as $key => $value) {
            FeedReader($key, $value);
        }
        break;
}

# ------------------------------- Functions ------------------------------------

// Erzeugen aller Variablen und Profile 
function Install($feeds, $update) 
{
    // HTML Boxes for Feeds 
    foreach($feeds as $key => $value) {
        $vid = CreateVariableByName($_IPS['SELF'], $key, 3);
        IPS_SetVariableCustomProfile($vid, '~HTMLBox');
        IPS_SetIcon($vid, "Talk");
    }
    // Manueller Update Button
    $vpn = "IPS.Update";
    $vid = CreateVariableByName($_IPS['SELF'], "Update", 1);
    CreateProfileInteger($vpn, 'Script', '', '', 0, 0, 0, 0, $update);
    IPS_SetVariableCustomProfile($vid, $vpn);
    IPS_SetVariableCustomAction($vid, $_IPS['SELF']);
    IPS_SetPosition($vid, -1);
    SetValue($vid, 0);
}

// Funktion zur Datums Formatanpassung, kann individuell verändert werden. 
function FeedReader($name, $url) 
{
    // Individuellen Parameter anhängen um Cacheing zu vermeiden
    //$hit = date("YmdHi", time());
    //$url = str_replace('<HIT>', $hit, $url);
    
    $xml = simplexml_load_file($url);
    //print_r($xml);
    //setlocale(LC_TIME, 'deu_deu');
    date_default_timezone_set('Europe/Berlin');
    $news_count = count($xml->channel->item); // Anzahl der im RSS Feed vorhandenen News 
    // Letztes Update und Lebenszeit (Time To Live)
    $news_last = $xml->channel->lastBuildDate;
    $news_ttl = 60; // $xml->channel->ttl;
    #echo $news_count;
    $news_want = 100; // Anzahl der gewünschten, anzuzeigenden News 
    // Wenn Anzahl der vorhandenen News kleiner der gewünschten News ... 
    if($news_count < $news_want) {
        // dann Anzahl der vorhandene News gleich den gewünschten News. 
        $news_want = $news_count;
    } 
    // Update Time
    $update = strtotime($news_last) + (($news_ttl)*60);
    if($update <= time()) {
        //IPS_LogMessage('FEEDS', 'Update Time:'. $update);
        $update = time() + ($news_ttl*60);
    }
    $next = "<div style='font-size:14px;'>Nächste Aktualisierung am ".date("d.m.",$update)." um ".date("H:i",$update)." Uhr.</div><br />";
    // HTML Styles, individuell anpasspar
    $style = "";
    $style = $style.'<style type="text/css">';
    $style = $style.'table {width:100%;border-collapse: collapse;}';
    $style = $style.'td.rss {vertical-align: top;text-align:left;padding:5px 10px 5px 10px;border: 1px solid rgba(255, 255, 255, 0.2);}';
    $style = $style.'tr:nth-child(even) {background-color: rgba(0, 0, 0, 0.3);}';
    $style = $style.'a.rlink { color: rgba(128, 128, 0, 1.0); text-decoration:none; font-weight:bold;}';
    $style = $style.'div.rtitle { float:left;}';
    $style = $style.'div.rctor { clear:both; color: rgba(192, 192, 192, 0.7); font-style:italic; font-size: small; padding: 2px 0px 5px 0px;}';
    $style = $style.'div.rdate { float:right; color: rgba(192, 192, 192, 0.5); font-size: small;}';
    $style = $style.'div.rdesc { font-size: smaller; width:90%;}';
    $style = $style.'</style>';
    // Feed in HTML Table umwandeln
    $feed  = $style.$next.'<table>'; 
    //Hier werden die News, in der gewünschten Anzahl, eingelesen und formartiert. 
    for($i=0; $i<$news_want; $i++) { 
        $item = $xml->channel->item[$i]; 
        $news = $item->title; 
        $news = ConvertEntity($news); 
        $desc = ConvertEntity($item->description);
        $link = $item->link; 
        $date = $item->pubDate; 
        $date = FormatDate($date); 
        $cat  = $item->category;
        $ctor = $item->children('http://purl.org/dc/elements/1.1/')->creator;
        // build html entry
        $feed .= '<tr><td class="rss">';
        $feed .= '<div class="rtitle"><a class="rlink" href="'.$link.'" target="_blank">'.$news.'</a></div>';
        $feed .= '<div class="rdate">'.$date.'</div>';
        $feed .= '<div class="rctor">'.$ctor.' - '.$cat.'</div>'; 
        $feed .= '<div class="rdesc">'.$desc.'</div>';
        $feed .= '</td></tr>'; 
    } 
    // Fertig
    $feed .= '</table>';
    // Fürs Webfront in Variable schreiben (String-Variable mit ~HTMLBox Profil)
    $vid = CreateVariableByName($_IPS['SELF'], $name, 3);
    SetValue($vid, $feed);
    // Neuen Aktualisierungstimer erzeugen
    CreateEventByName($_IPS['SELF'], $name.'Update', 1, $update); 
}

// Funktion zur Datums Formatanpassung, kann individuell verändert werden. 
function FormatDate($date) { 
    $today = time();
    $today = date("d.m.Y" , $today);
    $yesterday = date("d.m.Y", strtotime("-1 days"));
    $publ = date("d.m.Y", strtotime($date)); 
    // bessere Lesbarkeit der Datumsangabe
    if($today == $publ) {
        $publ = 'Heute, '.strftime('%d %B %Y %H:%M:%S', strtotime($date));
    }
    else if($yesterday == $publ) {
        $publ = 'Gestern, '.strftime('%d %B %Y %H:%M:%S', strtotime($date));
    }
    else {
        $publ = strftime('%A, %d %B %Y %H:%M:%S', strtotime($date));
    }
    return $publ; 
} 

// Funktion zur News Formatierung , kann individuell erweitert werden. 
function ConvertEntity($news){ 
    $news=strip_tags($news); 
    $news=html_entity_decode($news); 
    $news=str_replace("         ", " ", $news); 
    $news=str_replace("ö", "ö", $news); 
    $news=str_replace("Ãœ", "Ü", $news); 
    $news=str_replace("ü", "ü", $news); 
    $news=str_replace("ä", "ä", $news); 
    $news=str_replace("ß", "ß", $news); 
    $news=str_replace("&amp;ndash;", "-", $news); 
    $news=str_replace('&amp;#039;', "`", $news); 
    $news=str_replace("&amp;", "&", $news); 
    $news=str_replace("Ö", "Ö", $news); 
    $news=str_replace("„", "", $news); 
    $news=str_replace("“", "", $news); 
    $news=str_replace("&ndash;", "-", $news); 
    $news=str_replace("„", "", $news); 
    $news=str_replace("“", "", $news); 
    $news=str_replace("„", "", $news); 
    $news=str_replace("–", "-", $news); 
    $news=str_replace("–", "-", $news); 
    $news=preg_replace("/\r|\n/s", "", $news); 
    return $news; 
}

// Erzeugt ein zyklisches Event
// id:      int - Parent 
// name:    string - Event name
// type:    0 => Legt ein “ausgelöstes” Ereignis an
//          1 => Legt ein “zyklisches” Ereignis an
//          2 => Legt ein “Wochenplan” Ereignis an
// time     int - timestamp
function CreateEventByName($id, $name, $type, $time) 
{ 
    if($time < time()) {
        return -1;
    }

    $eid = @IPS_GetEventIDByName($name, $id); 
    if($eid===false) { 
        $eid = IPS_CreateEvent($type); 
        IPS_SetParent($eid, $id); 
        IPS_SetName($eid, $name); 
    } 

    // einmaliges Event
    IPS_SetEventCyclic($eid, 1, 0, 0, 0, 0, 0); 
    IPS_SetEventCyclicDateFrom($eid, (int)date('j',$time), (int)date('n', $time),  (int)date('Y', $time)); 
    IPS_SetEventCyclicDateTo($eid, 0, 0, 0); 
    IPS_SetEventCyclicTimeFrom($eid, (int)date("H", $time), (int)date("i", $time), (int)date("s", $time)); 
    IPS_SetEventCyclicTimeTo($eid, 0, 0, 0);
    IPS_SetEventActive($eid, true); 
    return $eid; 
}

// Erzeugt eine Variable unterhalb {id} mit dem Namen {name} vom Typ [type}
// Existiert die Variable schon wird diese zurückgeliefert.
// Types: 0 = Boolean, 1 = Integer, 2 = Float, 3 = String
function CreateVariableByName($id, $name, $type) 
{ 
    $vid = @IPS_GetVariableIDByName($name, $id); 
    if($vid===false) { 
        $vid = IPS_CreateVariable($type); 
        IPS_SetParent($vid, $id); 
        IPS_SetName($vid, $name); 
    }
    return $vid; 
}

// Erzeugt ein Variablenprofil vom Typ {type} mit Name n{name} 
function CreateProfile($name, $type)
{
    if(!IPS_VariableProfileExists($name)) {
        IPS_CreateVariableProfile($name, $type);
    } 
    else {
        $profile = IPS_GetVariableProfile($name);
        if($profile['ProfileType'] != $type)
        throw new Exception("Variable profile type does not match for profile ".$name);
    }
}

// Erzeugt ein Integer-Variablenprofil
function CreateProfileInteger($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $step, $digits, $asso = NULL)
{
    CreateProfile($name, 1);

    IPS_SetVariableProfileIcon($name, $icon);
    IPS_SetVariableProfileText($name, $prefix, $suffix);
    IPS_SetVariableProfileDigits($name, $digits);

    if(sizeof($asso) !== 0){
        $minvalue = 0;
        $maxvalue = 0;
    } 
    IPS_SetVariableProfileValues($name, $minvalue, $maxvalue, $step);

    if(sizeof($asso) !== 0){
        foreach($asso as $ass) {
        IPS_SetVariableProfileAssociation($name, $ass[0], $ass[1], $ass[2], $ass[3]);
        }
    }
}
################################################################################
?>

Viel Erfolg
Heiko

2 „Gefällt mir“

#pitti
Danke Heiko
Das funktioniert.
Gruß Helmut

Hallo,

danke für das Skript.
Habe ich direkt eingebunden. Tolle Idee.

Grüße
Björn

Moin pitty,
danke dir und natürlich auch obicom für das Script:-) Ich habe es auch gleich für andere Feeds missbraucht. Da ich Nordlicht bin wollte ich Buten&Binnen (Bremer Regionalnachrichten, Die neusten Nachrichten von butenunbinnen.de) einbinden was zu einem Fehler führte. Mit 3 kleinen Änderungen geht das aber auch:
1.

date_default_timezone_set(‚Europe/Berlin‘);

if (isset($xml->channel->item)){

    $news_count = count($xml->channel->item); // Anzahl der im RSS Feed vorhandenen News 

}

if (isset($xml->entry)){

    $news_count = count($xml->entry); // Anzahl der im RSS Feed vorhandenen News 

}

for($i=0; $i<$news_want; $i++) {

    if (isset($xml->channel->item)){

        $item = $xml->channel->item[$i]; 

    }

    if (isset($xml->entry)){

        $item = $xml->entry[$i]; 

    }
    $link = $item->link; 
    if (isset($link['href'])){
        $link = $item->link['href']; 
    }

Vielleicht hilft es ja auch anderen mit weiteren Feeds.

Ralf

1 „Gefällt mir“