Read rss based news and reviews from other website 
June 12th, 2009, 09:01 AM
| | Familiar Sight | | Join Date: Aug 2008
Posts: 160
| |
Hey all,
I want to read news and reviews from a website http://carsguide.news.com.au/site/rss/
and want to populate on my website. How can i read that rss and show on my website using php
kind regards,
Mohsin Rafique
| 
June 12th, 2009, 10:18 AM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: Read rss based news and reviews from other website Quote:
Originally Posted by neovantage How can i read that rss | any XML reader will do (DOMDocument, SimpleXML, …) Quote:
Originally Posted by neovantage and show on my website using php | you could use XSLT to make the RSS into HTML directly. or use the XML reader to output the appropriate data.
| 
June 15th, 2009, 10:48 AM
| | Familiar Sight | | Join Date: Aug 2008
Posts: 160
| | | re: Read rss based news and reviews from other website
Hey Sir,
I have found a script which do this all for you and we just needs to pass the RSS URl of the website to whom we want to grab the news.
It's really very nice script.
I want to share this with this great community of experts as may be this will be helpful for those like me.
here is the URL: A PHP script to get the contents of a remote RSS file -
<?
-
/*
-
======================================================================
-
Get, cache, and output contents of a RSS XML file
-
Author: George at JavaScriptKit.com/ DynamicDrive.com
-
Created: Feb 1st, 2006. Updated: Feb 1st, 2006
-
======================================================================
-
*/
-
-
header('Content-type: text/xml');
-
-
// -------------------------------------------------------------------
-
// Enter list of possible RSS feeds to fetch inside array:
-
// -------------------------------------------------------------------
-
-
$rsslist=array(
-
"CNN" => "http://rss.cnn.com/rss/cnn_topstories.rss",
-
"BBC" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
-
"news.com" => "http://news.com.com/2547-1_3-0-5.xml",
-
"slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
-
"dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new"
-
);
-
-
$cachefolder="cache"; //path to cache directory. No trailing "/". Set dir permission to read/write!
-
-
// -------------------------------------------------------------------
-
// Determine which RSS file to actually fetch
-
// Based on the value of the "id" parameter of the URL string mapping to the RSS array's key
-
// -------------------------------------------------------------------
-
-
$rssid=$_GET['id'];
-
$rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("Error: Can't find requested RSS in list.");
-
$localfile=$cachefolder. "/" . urlencode($rssurl); //Name cache file based on RSS URL
-
-
// -------------------------------------------------------------------
-
// Get the minutes to cache the local RSS file based on "cachetime" parameter of URL string
-
// -------------------------------------------------------------------
-
-
$cacheminutes=(int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater)
-
-
// -------------------------------------------------------------------
-
// fetchfeed() gets the contents of an external RSS feed,
-
// and saves its contents to the "cached" file on the server
-
// -------------------------------------------------------------------
-
-
function fetchfeed(){
-
global $rssurl, $localfile;
-
$contents=file_get_contents($rssurl); //fetch RSS feed
-
$fp=fopen($localfile, "w");
-
fwrite($fp, $contents); //write contents of feed to cache file
-
fclose($fp);
-
}
-
-
// -------------------------------------------------------------------
-
// outputrsscontent() outputs the contents of a RSS feed using the cached local RSS file
-
// It checks if a cached version of the RSS feed is available, and if not, creates one first.
-
// -------------------------------------------------------------------
-
-
function outputrsscontent(){
-
global $rssurl, $localfile, $cacheminutes;
-
if (!file_exists($localfile)){ //if cache file doesn't exist
-
touch($localfile); //create it
-
chmod($localfile, 0666);
-
fetchfeed(); //then populate cache file with contents of RSS feed
-
}
-
else if (((time()-filemtime($localfile))/60)>$cacheminutes) //if age of cache file great than cache minutes setting
-
fetchfeed();
-
readfile($localfile); //return the contents of the cache file
-
}
-
-
outputrsscontent();
-
?>
-
| 
June 15th, 2009, 01:36 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: Read rss based news and reviews from other website
so you didn't want to process the RSS file in the first place?
EDIT:
better use $_GLOBAL['name'] than global $name
maybe OOP can improve the code even more.
| 
June 15th, 2009, 01:42 PM
| | Familiar Sight | | Join Date: Aug 2008
Posts: 160
| | | re: Read rss based news and reviews from other website
i don't get you sir.
| 
June 15th, 2009, 01:51 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: Read rss based news and reviews from other website
I thought you wanted to do anything to the RSS. but looking at the script, it does only fetch the feed, thus my question.
| 
June 15th, 2009, 01:59 PM
| | Familiar Sight | | Join Date: Aug 2008
Posts: 160
| | | re: Read rss based news and reviews from other website
yep that's all i want to do for the time being now Sir
| 
June 15th, 2009, 02:00 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: Read rss based news and reviews from other website
then I misunderstood your question. the mentioned techniques are used to process RSS (which obviously includes loading)…
| 
June 15th, 2009, 02:20 PM
| | Familiar Sight | | Join Date: Aug 2008
Posts: 160
| | | re: Read rss based news and reviews from other website
On more question sir i am stuck in Thickbox Image Gallery
I have integrated Thickbox Gallery images for multiple images. So that once a member/client/visitor view the images he/she can navigate easily.
It just do not show any image if i used it's property rel means same rel element and value. It does not work. Can some body view on my script and tell me what is the problem behind this issue.
here is the live demo of the my work
Go to this link http://www.neovantage.net/projects/carsbay/search.php
Then click on Start Finding button. Once the page will open it show only one record. Click on Dealer Enquiry Link or click on images. it will take to you on the detail page. There you will see the pictures list and here i integrated Thickbox image gallery. when you will click on thumbnail then you will get my problem that it loads nothing just keep on browsing the page n that's it
kindly solve my problem Sir.
| 
June 15th, 2009, 02:24 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: Read rss based news and reviews from other website
I've alread read that…
please respect the Posting Guidelines and don't hijack your own thread.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|