0
我在運行cron作業時遇到問題。如何在cron作業中加載xml
這裏是我的代碼:
<?php
$doc = new DOMDocument();
$doc->load('http://www.all-news.in/feed');
$items = $doc->getElementsByTagName("item");
mysql_connect('host','username','pass');
mysql_select_db('dbname');
$i=0;
foreach($items as $itemname)
{
// Here Business logic for Inserting the data
}
echo $i.' Imported';
?>
當我運行在瀏覽器這個文件,它工作正常,但cron的執行時,我已經得到了以下錯誤:
<br />
<b>Warning</b>: DOMDocument::load(http://www.all-news.in/feed) [<a href='domdocument.load'>domdocument.load</a>]: failed to open stream: Connection timed out in <b>/home/content/98/7509598/html/amz/social-bookmark.in/cron_jobs/all_news.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>: DOMDocument::load() [<a href='domdocument.load'>domdocument.load</a>]: I/O warning : failed to load external entity "http://www.all-news.in/feed" in <b>/home/content/98/7509598/html/amz/social-bookmark.in/cron_jobs/all_news.php</b> on line <b>4</b><br />
0 Imported
是的,謝謝,我已經整理出來了。問題出在主機帳戶上。當我的cron作業運行時,他們處於維護模式。這就是爲什麼我有錯誤。非常感謝您的時間.. – Avinash 2011-03-04 13:48:34