PHP - Rss Feed Help
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 Similar TutorialsI'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 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>"; 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 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> 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 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. 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 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? 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. 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 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 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! 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? hi i know eval is not best way to run php code via database but its required to me. What is happening i am reading a feed and if i use eval it just repeat same rss links but if i put a direct code it show proper feed. here is my code which works proper $xml = simplexml_load_file($feedurl); foreach ($xml->channel->item as $item) { echo $item->title . "\n"; echo $item->link . "\n"; } results of above code are fine. Code: [Select] Feed one title feed one link feed two title feed two link feed three title feed three link and so on for 10 times as 10 feeds are available...... But if i use eval my database contains <?php echo $item->title . "\n"; echo $item->link . "\n"; ?> and i run it like this $xml = simplexml_load_file($feedurl); foreach ($xml->channel->item as $item) { eval('?>' . $fromadatabase['code'] . '<?php '); } and i get this results Code: [Select] Feed one title feed one link Feed one title feed one link Feed one title feed one link and so on...... means it just repeat first feed for 10 times Thanks for any help. 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! I am a php programmer but I am not so good with XML files. For a price comparison website, I need to parse the Amazons XML feed to store product data into the database. Can anyone please help me to find out such a simple script to parse Amazon XML product feed??? (Actually, I need each product data in array to be stored into the database) Thank you in advance. |