PHP - Problem With Stale Rss Feed
I am trying to troubleshoot a problem with a php script that incorporates an RSS feed (with Magpie 0.72.) I did not code the site, and am trying to retrace the original logic. Tech support at my web hosting firm said that the problem was in line 4 of INDEX.PHP:
1. <?php 2. require ("\\\\(HOSTING SITE NAME)\\config.inc.php"); 3. require ($CONFIG['admin_dir'].'page.class.php'); 4. require ($CONFIG['admin_dir'].'function.inc.php'); 5. $currentFile = $_SERVER["SCRIPT_NAME"]; 6. $parts = explode('/', $currentFile); 7. $currentFile = $parts[count($parts) - 1]; 8. $currentFile = preg_replace("/\.\w+$/", "", $currentFile); 9. $page = new page($currentFile, $CONFIG); 10. if ( !$page->isActive() ) { a. $currentFile = $CONFIG['404_page']; b. $page = new page($currentFile, $CONFIG); 11. } 12. require ($CONFIG['include_dir'].$page->getTemplate().'.php'); 13. ?> The RSS feed is in an INCLUDES directory that is defined by CONFIG.INC.PHP: <?php # URL to the RSS feed // CIO.com $FEED_URL = "http://feeds.cio.com/cio/feed/articles?format=rss"; $NUM_ITEMS = 5; require($CONFIG['include_dir'].'magpierss-0.72\rss_fetch.inc'); # Fetch the feed error_reporting(E_ERROR); $rss = fetch_rss($FEED_URL); if($rss) { # Split array with our amount of items $items = array_slice($rss->items, 0, $NUM_ITEMS); $rssChannelTitle = $rss->channel['title']; $rssChannelLink = $rss->channel['link']; // $rssChannelDesc = $rss->channel['description']; $output = ""; $output .= ""; foreach ( $items as $item ) { $output .= '<li class="item">'; $output .= '<a class="itemLink" target="blank" href="'; $output .= $item['link'] . '">'; $output .= $item['title']; $output .= '</a>'; /* CIO's feed contains ads. $output .= '<p class="description">' . $item['description'] . '</p>'; */ $output .= "</li>"; } $output .= ""; } ?> <?php if($rss) { ?> <div class="rssFeed <?php echo $rssChannelTitle ?>"> <h1> <a href="<?php echo $rssChannelLink ?>"> <?php echo $rssChannelTitle ?> </a> </h1> <!-- <h2><?php echo $rssChannelDesc ?></h2> --> <ul class="itemList"> <?php echo $output ?> </ul> </div> <?php } ?> What am I missing? Similar TutorialsHey Guys, First Post! Yay I have a problemo, I feel really stupid about having to ask this question. But basically I can't get a new line when I echo output in a script I am writing for my website. Here is the code: echo $newsentry; echo '_______ Read More..'; I tried '\n' I tried using " (double quotes) I have used ' (single quotes) I have positioned the Line Feed '\n' at the begining of an output, and at the end. Neither made any difference. I tried using carriage return '\r' too. Nothing. I haven't coded in PHP for a while, well nothing basic (I know that sounds rediculas but it has been mostly Apps etc, Client Scripts blah blah blah, but I haven't had to echo with a new line for a few years. Probably the last website which I wrote with my friend. So I checked the PHP manual, and I am clearly missing something when I am reading it, I understood it to mean (which as you can see from my code, is what I am currently doing), that you could just somehow type: echo "some string and it carries on to the second line"; However as I first thought, this makes no difference. Could this be a configuration on the Box that hosts this Site?? Sorry for sounding so stupid guys, I appreciate your help. -Craig Hi All, I'm trying to incorporate a BBC Sport RSS Feed into my website. The following code will show me the news feeds as text and I can include the url's as text also but want to turn this into a clickable url. How do I do this, I cant work it? please help. $feed_url = "http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/teams/s/shrewsbury/rss.xml"; // Get data from feed file $response = file_get_contents($feed_url); // Insert XML into structure $xml = simplexml_load_string($response); // Browse structure foreach($xml->channel->item as $one_item) echo $one_item->title."<BR>"; I'm lost on this one. This code works fine in Firefox, but not my IE8. I think it has something to do with the <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> line, but i'm not sure. IE says "Internet Explorer cannot display this feed" and "A name contained an invalid character. Line: 7 Character: 701." Any ideas? <?php header('Content-Type: text/xml'); ?> <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <?php include('../vars.php'); ?> <rss version="2.0"> <channel> <title>Newsfeed</title> <description>News and Updates</description> <link>http://www.example.com</link> <language>en-us</language> <?php require_once("../conn.php"); $query = "SELECT * FROM news"; $data = mysqli_query($db, $query); while ($row = mysqli_fetch_array($data)) { echo '<item>'; echo ' <title>' . $row['title'] . ' - ' . substr($row['content'], 0, 32) . '...</title>'; echo ' <link>http://www.example.com/new.php?newsid=' . $row['newsid'] . '</link>'; //echo ' <pubDate>' . $row['date'] . '</pubDate>'; echo ' <description>' . $row['content'] . '</description>'; echo '</item>'; } ?> </channel> </rss> Hi I get an error when trying to add a link to my rss feed Code: [Select] <link>http://www.jobjar.co.uk/jobdetails.php?keywords=lon0014&page=1</link>Something to do with the last part of the link because when I remove the page=1 it then works. How can I resolve this? Also, will I have to manually update my xml file for rss feeds or can it be updated automatically? If so how? Thanks I'm not sure you can do this but i would like to grab the image gif from the rss feed of yahoo weather. For instance http://weather.yahooapis.com/forecastrss?p=77056 I pulled this script from a tutorial online and it works great for displaying the temperature and condition and i realize those values are located within the xml. But i would like to grab the image located between the <description> tags (if you look at the source of the rss feed). I don't know if this is possible or not. Thanks. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Yahoo! Weather API RSS</title> <?php function retrieveYahooWeather($zipCode="92832") { $yahooUrl = "http://weather.yahooapis.com/forecastrss"; $yahooZip = "?p=$zipCode"; $yahooFullUrl = $yahooUrl . $yahooZip; $curlObject = curl_init(); curl_setopt($curlObject,CURLOPT_URL,$yahooFullUrl); curl_setopt($curlObject,CURLOPT_HEADER,false); curl_setopt($curlObject,CURLOPT_RETURNTRANSFER,true); $returnYahooWeather = curl_exec($curlObject); curl_close($curlObject); return $returnYahooWeather; } $localZipCode = "77056"; // Houston, Tx $weatherXmlString = retrieveYahooWeather($localZipCode); $weatherXmlObject = new SimpleXMLElement($weatherXmlString); $currentCondition = $weatherXmlObject->xpath("//yweather:condition"); $currentTemperature = $currentCondition[0]["temp"]; $currentDescription = $currentCondition[0]["text"]; ?> </head> <body> <h1>Houston, TX</h1> <ul> <li>Current Temperatu <?=$currentTemperature;?>°F</li> <li>Current Description: <?=$currentDescription;?></li> </ul> </body> </html> Hi, I have a small piece of code that creates an RSS feed using a mysql database. The issue is the page itself is blank however if I right click and view source I can see all the feed there. I convert the dat time field into a standard RSS date field. The web address is http://vinovote.com/news/feed.php My code is as follows Code: [Select] <?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> <rss version="2.0"> <channel> <title>Vinovote.com</title> <description>The Latest News And Views From Around The Web</description> <link>http://www.vinovote.com/</link> <copyright>Your copyright information</copyright> <?php require_once('../Connections/connection.php'); mysql_select_db($database_vinovotedb, $vinovotedb); $doGet = mysql_query("SELECT feed_content.feed_content_id, feed_content.feed_id, feed_content.url, feed_content.title, feed_content.content, feed_content.item_time, Date_FORMAT(feed_content.item_time,'%a, %d %b %Y %T') AS pubDate FROM feed_content order by item_time desc LIMIT 50 ", $vinovotedb) or die(mysql_error()); while($result = mysql_fetch_array($doGet)){ ?> <item> <title> <?php echo $result['title']; ?></title> <description> <?php echo $result['content'];?></description> <link><?php echo $result['url'];?></link> <pubDate> <?php echo $result['pubDate']; ?></pubDate> </item> <?php } ?> </channel> </rss> Hello all That forum is my last desperate attemp to do what i want to do. Ok here is the story I want to create a simple rss feed in conjuction with php and mysql. I dont want admin areas ect , i just want when i insert a new listing to my database to be able shown up to my (future) rss subscribers. To be more technically specific i want to show to my surfers updates about 2 tables in my database not all the tables. The example i found so far were about only 1 table, plus i was encounting errors to my script. I would like some ideas, directions if someone is kind enough to help a sad developer Thanks in advance! Does anybody have any recommendations for PHP scripts to pull in a Twitter feed? I've tried several but each seem to just give me error messages! I basically just need a PHP alternative so that the tweets can be read by search engines. Thanks. Hello! I'm trying to develop some kind of RSS news aggregator and I want to show only feeds younger than 1day. I figured i could transform RSS pubDate to timestamp (strtotime()), but there are some feeds without timestamp (like: http://izklop.com/xmldata/rsslinks.xml). Is there any other way to do it, so I could find timestamp from those feeds without pubdate? If there isn't any other way, do You think it is ok, to just show last 5 feeds? I hope I made my self clear, and please forgive me for my English Hi, I am reading a feed with this code foreach ($xml->channel->item as $item) { echo $item->title; echo '<br>'; } and outputs Code: [Select] title 1 title 2 title 3 .... and so on until 10 I wants in reverse order to output last rss feed first like: Code: [Select] title 10 title 9 title 8 .... and so on until 1, how can i do it? i tried with rsort($xml->channel->item) butt getting this error: Quote Warning: rsort() expects parameter 1 to be array, object given in Thanks for help I have tried sitemap.org and a few others but have not found anything that will give the results I am after. I have a blog site that has a URL and a Description for the URL and wish to have the description show as the anchor text which is linked to the URL, all data is taken from MySQL. Does anyone have a code that will generate something like this ? I'm been searching and can't seem to figure this out. I want to take an RSS feed from a news site and display it on my site. any help? hi all, i am trying to just get a couple things from this RSS feed: http://www.sierraavalanchecenter.org/bottomline-rss.php I would like to grab the danger rose image on the left, the text that tells of the Avalanche danger ie... "Avalanche Danger Remains LOW..." and the date. I have tried using a few things like: $html = 'http://www.sierraavalanchecenter.org/bottomline-rss.php';$dom = new DOMDocument;$dom->loadHTML($html);$xpath = new DOMXPath($dom);$res = $xpath->query('//div[@id="dangericon"]');if ($res->item(0) !== NULL) { $test = $res->item(0)->nodeValue;}() ...without any luck. Anyone have some advice for me? thanks! hi i want to add some content to my site using xml rss i have a feed i want to show, and the only thing i can find to show it on my page or widgets but they dont look like i want it to look, so i want to make a php script that reads the xml file and then parses it into my website dont know if this is even possible ... but if its possible, is it also possible to filter the feed on certain keywords? I have a php script that saves some data as a .xml document. When I view this in my browser I can subscribe to the feed (I am using firefox). However I asked someone else to see if they could subscribe (they were using IE) but the couldn't. Therefore how can users subscribe to my feed? Will only some be able to subscribe? Thanks for any help. Hi, I've written some code to take information from an SQL database and write it out in the RSS format (Although it doesn't validate). The problem is i'd like the page to have the .rss (or .xml) file extension, I'm not sure if there's any advantages in having this but thought i'd ask. I've got the following code: Code: [Select] <?php header('Content-type: text/xml'); print '<?xml version="1.0"?>'; print '<rss version="2.0">'; print '<channel>'; include("phpfunctions.php"); db_connect(); //select all from users table $select="SELECT title, link, description FROM news"; $result = mysql_query($select) or die(mysql_error()); //If nothing is returned display error no records if (mysql_num_rows($result) < 1) { die("No records"); } //loop through the results and write each as a new item while ($row = mysql_fetch_assoc($result)) { $item_title = $row["title"]; $item_link = $row["link"]; $item_desc = $row["description"]; print '<item>'; print '<title>' . $item_title . '</title>'; print '<link>' . $item_link . '</link>'; print '<description>' . $item_desc . '</description>'; print '</item>'; } print '</channel>'; print '</rss>'; ?> This seems to work fine as i get what i expect and i'm assuming i can do the same to output .xml but is there a way to have it in a proper .rss / .xml file so that an aggregator or someone could read this properly. Cheers, Reece Hi, I have a problem with an RSS Feed. the error im getting on the W3C validator is this: This feed does not validate. * line 1, column 0: XML parsing error: <unknown>:1:0: syntax error [help] Query couldn't be executed In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation. * "text/xml" media type is not specific enough [help] .htaccess AddType application/x-httpd-php .xml rss.php <? //Set XML header for browser header('Content-type: text/xml'); //Create the heading/channel info for RSS Feed $output = '<rss version=\"2.0\">'; $output .= '<channel>'; $output .= '<title>Muzo Feed</title>'; $output .= '<description>Your RSS Feed Description</description>'; $output .= '<link>http://mi-linux.wlv.ac.uk/~0703272</link>'; //Individual Items of our RSS Feed //Connect to a database and and display each new item in our feed //Connect to DB $host = "localhost"; //Name of host $user = "0703272"; //User name for Database $pass = "rachel123"; //Password for Database $db = "db0703272"; //Name of Database mysql_connect($host,$user,$pass); //Create SQL Query for our RSS feed $sql = "SELECT `title`, `webaddress`, `message`, `date_added` FROM `messages`ORDER BY `date_added` DESC LIMIT 0 , 15"; $result = mysql_query($sql) or die ("Query couldn't be executed"); //Create Loop for the individual elements in the RSS item section while ($row = mysql_fetch_array($result)) { $output .= '<item>'; $output .= '<title>'.$row['title'].'</title>'; $output .= '<link>http:/mi-linux.wlv.ac.uk/~0703272/blog.php'.$row['link'].'</link>'; $output .= '<message>'.$row['message'].'</description>'; $output .= '<date_added>'.$row['date'].'</pubDate>'; $output .= '</item>'; } //Close RSS channel $output .= '</channel>'; $output .= '</rss>'; //Display output in browser echo $output; ?> any ideas? I was wondering what approach you would take to code a news feed like Facebook has. I have a status, users, and photo mysql tables. Would you create a new table called "feed" and have a query run everytime someone updates, inserts, etc anything in those three tables? or something else? What would be the most efficient way to code a news feed? Thanks in advanced! |