473,657 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read rss based news and reviews from other website

245 New Member
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 1963
Dormilich
8,658 Recognized Expert Moderator Expert
@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 New Member
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 Recognized Expert Moderator Expert
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 New Member
i don't get you sir.
Jun 15 '09 #5
Dormilich
8,658 Recognized Expert Moderator Expert
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 New Member
yep that's all i want to do for the time being now Sir
Jun 15 '09 #7
Dormilich
8,658 Recognized Expert Moderator Expert
then I misunderstood your question. the mentioned techniques are used to process RSS (which obviously includes loading)…
Jun 15 '09 #8
neovantage
245 New Member
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 Recognized Expert Moderator Expert
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
3832
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 based site with videos - NO, it's not a porn site though. I thought that I'd list the key requirements/specifications for my web site below and was wondering if some of you'd be so kind as to provide your thoughts on each and comment on them with...
1
1913
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" for all players parents to be able to read (Read-Only). I have the IMAP part down and can capture the email but am looking for some existing script to add webmail type appearance without all the bells and whistles - although the ability to handle...
8
6282
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 products features so I thought I may add my own review, information collected while creating a project in a live environment. I've to say, at first glance this product has a lot to offer and seems to be a better choice than InstallShield...
6
2326
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 products features so I thought I may add my own review, information collected while creating a project in a live environment. I've to say, at first glance this product has a lot to offer and seems to be a better choice than InstallShield...
1
1773
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 x minutes have elapsed return the XML from the file and then rewrite the XML file for the next user and reset the clock. If x minutes havent elapsed just return the XML from the file. Do I need to be concerned for any concurrent read/writes or...
7
1773
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 thing for the Palm OS and, unfortunately, DataOnTheRun is Pocket PC only. Can anyone please point me to reviews of such software? There seem to be dozens of these kinds of tools, but no where to go to research the differences.
6
7364
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 chunk of the file into a buffer, when it encounters the end of the file, will the EOF indicator be put into the buffer automatically just as an ordinary byte of the file, or do I have to do it manually?
11
1588
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 word instslled it give error in it i used com reference. i want to know is there is a way to read a doc when ms word is not instslled on the server.
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.