• Resolved silafu

    (@silafu)


    I’m trying to execute a php with a cron job. That php should read some xml feed and write the contents to a file.

    The code, the feed reading part, looks like this:

    <?php
    include_once(ABSPATH.WPINC.'/rss.php');
    $postCount = 0;
    $feed = fetch_rss('https://www.infovalutar.ro/bnr/rss');
    $items = array_slice($feed->items,0, 30); ?>
    
    <?php if (!empty($items)) : ?>
    <?php foreach ($items as $item): ?>
    
    <li><p><span class="slider-item"><?php echo $item['title']; ?></span> <?php echo $item['description']; ?></p></li>
    
    <?php endforeach; ?>
    <?php endif; ?>

    This works if inserted in page template. Once I try to execute it with a cron job I get in mail the following error:
    Warning</b>: include_once(ABSPATHWPINC/rss.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in <b>/home/...

    What’s wrong? Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter silafu

    (@silafu)

    I see that I get no answer so I will go into more details.

    The cron job looks like this:
    php /home/site/public_html/wp-content/themes/theme/widgets/curs/write-curs.php >/dev/null

    “write-curs.php” contains this:

    <?php ob_start(); ?>
    <?php
    include_once(ABSPATH.WPINC.'/rss.php');
    $postCount = 0;
    $feed = fetch_rss('https://www.infovalutar.ro/bnr/rss');
    $items = array_slice($feed->items,0, 30); ?>
    
    <?php if (!empty($items)) : ?>
    <?php foreach ($items as $item): ?>
    
    <li><p><span class="slider-item"><?php echo $item['title']; ?></span> <?php echo $item['description']; ?></p></li>
    
    <?php endforeach; ?>
    <?php endif; ?>
    	  <?php $widget_cont = ob_get_contents();
    ob_end_flush();
    $fp = fopen("/home/site/public_html/wp-content/themes/theme/widgets/curs/curs.php","w");
    fwrite($fp, $widget_cont);
    fclose($fp);
    
    ?>

    If I succes in maikeing this work out I plan to include “curs.php” into templates.

    Can somebody tell me what causes that error?

Viewing 1 replies (of 1 total)
  • The topic ‘fetch_rss and cron jobs’ is closed to new replies.