|
Posted by Martin Mandl - m2m tech support on 03/23/07 09:41
On Mar 22, 11:46 pm, "eltower" <acachin...@gmail.com> wrote:
> adactio.com/journal/1202 has a very interesting PHP script which
> gathers RSS data from various feeds and prints them in an HTML table.
> He calls this a lifestream.
>
> Anyways, unfortunately, my knowledge of PHP is rather limited - I'd
> rather work with a stylesheet. It turns out that my local machine has
> PHP5, and the script works flawlessly. However, Bluehost, my hosting
> provider, has PHP 4.4.4. As a result, I'm getting a lot of exceptions
> thrown around. I think I figured out my way around the
> getElementsByTagName(), which should be get_elements_by_tagname() in
> PHP4, but I'm still getting heavy exceptions. I also googled and found
> that the date_default_timezone_set() function isn't supported in PHP4
> either.
>
> I'd appreciate it greatly if anyone could point out where the
> incompatibilities are - even if there's a better way of doing this RSS
> gathering, I'd just like to see anyway for educational purposes.
>
> My PHP source is the following (I've left out the HTML surrounding
> it):
> <?php
>
> date_default_timezone_set("Europe/Paris");
>
> $feeds = array(
> "feed1" => "http://...",
> "feed2" => "http://...",
> "feed3" => "http://...",
> "feed4" => "http://..."
> );
>
> $details = array("title","link");
>
> $list = array();
>
> $rss = new DOMDocument();
>
> foreach ($feeds as $name => $feed) {
>
> $rss -> load($feed);
>
> $items = $rss -> getElementsByTagName("item");
>
> foreach ($items as $item) {
>
> if ($item -> getElementsByTagName("pubDate") -> item(0)) {
> $date = $item -> getElementsByTagName("pubDate") ->
> item(0) -> nodeValue;
> } else {
> $date = $item -> getElementsByTagName("date") -> item(0) -> nodeValue;
>
> }
> $date = strtotime(substr($date,0,25));
>
> $list[$date]["name"] = $name;
>
> foreach ($details as $detail) {
>
> $list[$date][$detail] = $item ->
> getElementsByTagName($detail) -> item(0) -> nodeValue;
>
> }
> }
>
> }
>
> krsort($list);
>
> $day = "";
>
> foreach ($list as $timestamp => $item) {
>
> $this_day = date("F jS",$timestamp);
>
> if ($day != $this_day) {
>
> echo "</tbody>\n";
> echo "<thead>\n";
> echo "<tr>\n";
> echo "<th colspan=\"3\">";
> echo $this_day;
> echo "</th>\n";
> echo "</tr>\n";
> echo "</thead>\n";
> echo "<tbody>\n";
>
> $day = $this_day;
>
> }
>
> echo "<tr class=\"vevent_";
> echo $item["name"];
> echo "\">\n";
> echo "<th>";
> echo "<abbr class=\"dtstart\" title=\"";
> echo date("c",$timestamp);
> echo "\">";
> echo date("g:ia",$timestamp);
> echo "</abbr>";
> echo "</th>\n";
> echo "<td>";
> echo "<a class=\"url_summary\" href=\"";
> echo $item["link"];
> echo "\">";
> echo $item["title"];
> echo "</a>";
> echo "</td>\n";
> echo "<td class=\"icon\">";
> echo "<img src=\"images/";
> echo $item["name"];
> echo ".gif\" alt=\"";
> echo $item["name"];
> echo "\" />";
> echo "</td>\n";
> echo "</tr>\n";
>
> }
>
> ?>
>
> Many thanks,
>
> Adri
Dear Adri,
$rss->getElementsByTagName("item"); uses the a methode of the
DOMDocument class. Thus is most likely NOT your problem with a change
from PHP5 to PHP4.
I assume that the class itself is written for PHP5. Or your two PHP
setups just use different settings.
Good luck
Martin
-----------------------------------------------
online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
http://www.ea-geier.at
------------------------------------------------
m2m server software gmbh
http://www.m2m.at
Navigation:
[Reply to this message]
|