I have a PHP script that is parsing an RSS feed and entering the info in a db. I am using PHP5.
It is a .php page, and works like a charm when accessed through the web server & browser. (http://myhost.com/rssjob.php)
Now i want to set it up as a CRON job – however when i execute it through SSH/CRON job – it throws exceptions like ” Invalid argument supplied for foreach() ” in following code.
Question:
1. Why is there a delta in the results i get through accessing the PHP page throw the browser and when i try to execute it as a CRON job/SSH command line?? Is there something more i should specify for the php page to work well when accessed through SSH/commandline/cron job?
$xml = parseRSS(“http://www.myhost.com/rss/”);
//SAMPLE USAGE OF
foreach($xml['RSS']['CHANNEL']['ITEM'] as $item) {
//echo("<p>");
$title = $item['TITLE'];
$description = $item['DESCRIPTION'];
A quick solution (hack) is to call your script via HTTP from cron: