Jump to content

Saving web version of RSS to local file in PHP


gwledig

Recommended Posts

HI I'm working with Sharepoint which provides some pages as RSS, but the link is very messy and doesn't show up as an xml file which makes accessing the feed very hard for doing things like displaying RSS on a public Web page.  Basically  I want to save the RSS url/page contents (the feed url) to a file (.xml) which seems to work better with rss readers and stuff.

 

so here is a script I've been trying to use to basically save the page as an xml file:

 

 

<?php

$remoteFileContents=file_get_contents("https://vocal-external.liv.ac.uk/sites/catherallp-test/news/_layouts/listfeed.aspx?List={C1F668FA-F047-427F-93B0-8344EA008518}");

$localFilePath = "C:\Mowes\www";

$localFileName = "ok.xml";

$newFileHandle = fopen($localFilePath."/".$localFileName, "w");

fwrite($newFileHandle, $remoteFileContents);

fclose($newFileHandle);

?>

 

Unfortunately I get this error when running the php:

----------------------------------------

Warning: file_get_contents(https://vocal-external.liv.ac.uk/sites/catherallp-test/news/_layouts/listfeed.aspx?List={C1F668FA-F047-427F-93B0-8344EA008518}) [function.file-get-contents]: failed to open stream: Invalid argument in C:\Mowes\www\saverss.php on line 2

----------------------------------------

 

I've been using MOWES version of apache server which uses php 4 and also has 5 (I assume it's using 5).

 

Any ideas much appreciated!!! 

 

Gwledig

 

 

 

Try using Curl:

 

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://vocal-external.liv.ac.uk/sites/catherallp-test/news/_layouts/listfeed.aspx?List={C1F668FA-F047-427F-93B0-8344EA008518}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$remoteFileContents = curl_exec($ch);

$localFilePath = "C:\Mowes\www";
$localFileName = "ok.xml";
$newFileHandle = fopen($localFilePath."/".$localFileName, "w");
fwrite($newFileHandle, $remoteFileContents);
fclose($newFileHandle);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.