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
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.
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();
-
?>
-
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.
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.
yep that's all i want to do for the time being now Sir
Dormilich 8,658
Recognized Expert Moderator Expert
then I misunderstood your question. the mentioned techniques are used to process RSS (which obviously includes loading)…
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.
Dormilich 8,658
Recognized Expert Moderator Expert
I've alread read that…
please respect the Posting Guidelines and don't hijack your own thread.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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.
|
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?
|
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.
|
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...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |