Link to home
Start Free TrialLog in
Avatar of smetterd
smetterdFlag for United States of America

asked on

Get Feedburner feed and write its XML locally using PHP

I want to access the feed at

http://feeds.feedburner.com/BrownsvilleIndependentSchoolDistrict?format=xml

and write valid raw xml file locally with php

Thank you for any guidance you can offer ;-)
ASKER CERTIFIED SOLUTION
Avatar of Pierre François
Pierre François
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rinfo
rinfo

$url = "http://feeds.feedburner.com/BrownsvilleIndependentSchoolDistrict?format=xml"

    $str = file_get_contents($url);

    you can save/write string to a file

    $myfile = "NameOfTheFilewithPath";
    $fp = fopen($myfile, 'w');
    fwrite($fp, $str);
    fclose($fp);
   you can just download this file to your local system from web server.
    Please note that this will be a xml file.
This is an example how you can download the xml file using php
<?php

// define some variables
$local_file = 'rss.xml';
$server_file = 'Nameofthefilewithpath';//just put file name here and my earlier code like "rss.xml";

// set up basic connection
$conn_id = ftp_connect($ftp_server);//name of the server

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
    echo "Successfully written to $local_file\n";
} else {
    echo "There was a problem\n";
}

// close the connection
ftp_close($conn_id);

?>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smetterd

ASKER

Yes I had to switch to curl. Works great! Thanks to all!