Quote:
Originally Posted by wilsontoad To automatically import RSS feeds into Pligg using RSS Importer v0.5
1. Ensure your PHP is compiled with curl support (if it isn't you can still do this using curl from the command line but this HOWTO doesn't cover this)
2. Create a php file in your root web directory called importrss.php
3. Put the following in this file replacing the url, username and password below with your details:
<?php
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://www.yoururl.com/login.php');
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=whatever&password=whatever&processlogin= 1');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'http://www.yoururl.com/module.php?module=rss_import_do_import');
// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);
// CLOSE CURL
curl_close ($ch);
?>
4. Set up a crontab to run as follows, putting your path in the relevant place
01* * * * /usr/local/bin/php -f /insert-path-here/importrss.php >/dev/null 2>&1
5. Sit back and watch |
Thanks wilsontoad, this works great and it also works with RSS Importer v0.6
Nice job