Hi there,
Im very new to php, but have figured out it may be the solution to my problem
I have created a java application that grabs RSS feed from a file, (say yahoo news)
then displays it as a ticker (this works client side). The problem is that java applets arent allowed to read from non local files without the use of a certificate.
I think there might be a way of copying the xml / rss feed to my servers local folder using php e.g:
from : http://rss.news.yahoo.com/rss/topstories
to : http://www.example.com/afile.html
I have had a search on google but couldnt see any easy way of doing this, it was all mostly database related and I just want to save it as a local file.
Does anyone know a simple bit of php that will do this, or a bit of info that I should be looking at?
Thanks for any help
copying RSS feed / XML to local server (cloning to local)
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
file_get_contents() and file_put_contents() may be of interest.
thanks, I had to use a small modification sice Im using php5:
Thats the writting part working, now to get the other part to work, Im very thankful for your help
Code: Select all
<?php
function file_put_contents_php4 ($location, $whattowrite) {
if (file_exists($location)) {
unlink($location);
}
$fileHandler = fopen ($location, "w");
fwrite ($fileHandler, $whattowrite);
fclose ($fileHandler);
}
echo file_put_contents_php4("test.txt","Hello World. Testing!");?>Thats the writting part working, now to get the other part to work, Im very thankful for your help
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Did you try file_get_contents()?
yes it all works now, thank you.
My only problem is that its a bit slow, but Im playing around with it so it doesnt need to download the data every time the page is viewed.
thanks for your help, I was completely new to php until last week and would have been stuck without your help
Ill offer the software out free once its complete
My only problem is that its a bit slow, but Im playing around with it so it doesnt need to download the data every time the page is viewed.
thanks for your help, I was completely new to php until last week and would have been stuck without your help
Ill offer the software out free once its complete