473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Read rss based news and reviews from other website

245 100+
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
Jun 12 '09 #1
9 1956
Dormilich
8,658 Expert Mod 8TB
@neovantage
any XML reader will do (DOMDocument, SimpleXML, …)

@neovantage
you could use XSLT to make the RSS into HTML directly. or use the XML reader to output the appropriate data.
Jun 12 '09 #2
neovantage
245 100+
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

Expand|Select|Wrap|Line Numbers
  1. <?
  2. /*
  3. ======================================================================
  4. Get, cache, and output contents of a RSS XML file
  5. Author: George at JavaScriptKit.com/ DynamicDrive.com
  6. Created: Feb 1st, 2006. Updated: Feb 1st, 2006
  7. ======================================================================
  8. */
  9.  
  10. header('Content-type: text/xml');
  11.  
  12. // -------------------------------------------------------------------
  13. // Enter list of possible RSS feeds to fetch inside array:
  14. // -------------------------------------------------------------------
  15.  
  16. $rsslist=array(
  17. "CNN" => "http://rss.cnn.com/rss/cnn_topstories.rss",
  18. "BBC" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
  19. "news.com" => "http://news.com.com/2547-1_3-0-5.xml",
  20. "slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
  21. "dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new"
  22. );
  23.  
  24. $cachefolder="cache"; //path to cache directory. No trailing "/". Set dir permission to read/write!
  25.  
  26. // -------------------------------------------------------------------
  27. // Determine which RSS file to actually fetch
  28. // Based on the value of the "id" parameter of the URL string mapping to the RSS array's key
  29. // -------------------------------------------------------------------
  30.  
  31. $rssid=$_GET['id'];
  32. $rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("Error: Can't find requested RSS in list.");
  33. $localfile=$cachefolder. "/" . urlencode($rssurl); //Name cache file based on RSS URL
  34.  
  35. // -------------------------------------------------------------------
  36. // Get the minutes to cache the local RSS file based on "cachetime" parameter of URL string
  37. // -------------------------------------------------------------------
  38.  
  39. $cacheminutes=(int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater)
  40.  
  41. // -------------------------------------------------------------------
  42. // fetchfeed() gets the contents of an external RSS feed,
  43. // and saves its contents to the "cached" file on the server
  44. // -------------------------------------------------------------------
  45.  
  46. function fetchfeed(){
  47. global $rssurl, $localfile;
  48. $contents=file_get_contents($rssurl); //fetch RSS feed
  49. $fp=fopen($localfile, "w");
  50. fwrite($fp, $contents); //write contents of feed to cache file
  51. fclose($fp);
  52. }
  53.  
  54. // -------------------------------------------------------------------
  55. // outputrsscontent() outputs the contents of a RSS feed using the cached local RSS file
  56. // It checks if a cached version of the RSS feed is available, and if not, creates one first.
  57. // -------------------------------------------------------------------
  58.  
  59. function outputrsscontent(){
  60. global $rssurl, $localfile, $cacheminutes;
  61. if (!file_exists($localfile)){ //if cache file doesn't exist
  62. touch($localfile); //create it
  63. chmod($localfile, 0666);
  64. fetchfeed(); //then populate cache file with contents of RSS feed
  65. }
  66. else if (((time()-filemtime($localfile))/60)>$cacheminutes) //if age of cache file great than cache minutes setting
  67. fetchfeed();
  68. readfile($localfile); //return the contents of the cache file
  69. }
  70.  
  71. outputrsscontent();
  72. ?>
  73.  
Jun 15 '09 #3
Dormilich
8,658 Expert Mod 8TB
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.
Jun 15 '09 #4
neovantage
245 100+
i don't get you sir.
Jun 15 '09 #5
Dormilich
8,658 Expert Mod 8TB
I thought you wanted to do anything to the RSS. but looking at the script, it does only fetch the feed, thus my question.
Jun 15 '09 #6
neovantage
245 100+
yep that's all i want to do for the time being now Sir
Jun 15 '09 #7
Dormilich
8,658 Expert Mod 8TB
then I misunderstood your question. the mentioned techniques are used to process RSS (which obviously includes loading)…
Jun 15 '09 #8
neovantage
245 100+
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.
Jun 15 '09 #9
Dormilich
8,658 Expert Mod 8TB
I've alread read that…

please respect the Posting Guidelines and don't hijack your own thread.
Jun 15 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Bozo Schmozo | last post by:
Greetings! I've searched groups.google.com already to see if I can determine if using PHP/MySQL (if needed) for a web site I wish to develop. As the subject indicated, it will be a content...
1
by: Jim | last post by:
I'm wanting to add functionality to a website...This is for a kids sports team - would like ability for Team Managers to be able to send email and have it automatically show up on website "Inbox"...
8
by: theintrepidfox | last post by:
Dear Group My personal review of MimarSinan InstallAWARE Studio 2005 SE as a courtesy for everyone considering evaluating or buying this product. There are many reviews out there praising the...
6
by: theintrepidfox | last post by:
Dear Group My personal review of MimarSinan InstallAWARE Studio 2005 SE as a courtesy for everyone considering evaluating or buying this product. There are many reviews out there praising the...
1
by: David Arden Stevensonn | last post by:
Say I have an XML file on my website that gets read alot (by a c# aspx page) but written to occasionally (also by the same c# aspx page) . Its a simple caching situation based on time. Example: If...
7
by: Joe Wasik | last post by:
Hello, Currently I used Biomobility's DataOnTheRun for the Pocket PC. It's a little slow, but it does exactly what I need -- and it does it well. Unfortunately, now I need to have the same...
6
by: ericunfuk | last post by:
Hi ALL, I want to read a binary file(it's pic.tif file, I guess it's binary file?), then write it to a new file), I have several questions about this process: When I use fread() to read a...
11
by: sajithkahawatta | last post by:
i wrote a code to read a doc and display that data on web page. in asp.net i woked properly in my iis ms word is installed in this pc. but when i published in another sever in which there is no ms...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.