Grow your CSS skills. Land your dream job.

SimplePie problems

  • # May 16, 2010 at 10:46 pm

    so I’m trying to use the simplepie that chris talked about in screencast #55 http://css-tricks.com/video-screencasts/55-adding-rss-content-with-simplepie/.

    I’m getting an error with the last line of code. If I remove the code, the error comes up on the next line of php (now the last line of php code)

    Any help would be appreciated.

    Code:
    < ?php
    //get the simplepie library
    require_once('http://website.com/wp-content/themes/mr-munoz/inc/simplepie.inc');

    //grab the feed
    $feedPolitico = new SimplePie();
    $feedPolitico->set_feed_url(array(
    ‘http://feeds2.feedburner.com/CssTricks’,
    ));
    $feedPolitico->set_item_limit(3);

    //enable caching
    $feedPolitico->enable_cache(true);

    //provide the caching folder
    $feedPolitico->set_cache_location(‘cache’);

    //set the amount of seconds you want to cache the feed
    $feedPolitico->set_cache_duration(1800);

    //init the process
    $feedPolitico->init();

    //let simplepie handle the content type (atom, RSS…)
    $feedPolitico->handle_content_type();

    //grab the feed
    $feedSmashing = new SimplePie();
    $feedSmashing->set_feed_url(array(
    ‘http://smashingmagazine.com’,
    ));

    $feedSmashing->set_item_limit(3);

    //enable caching
    $feedSmashing->enable_cache(true);

    //provide the caching folder
    $feedSmashing->set_cache_location(‘cache’);

    //set the amount of seconds you want to cache the feed
    $feedSmashing->set_cache_duration(1800);

    //init the process
    $feedSmashing->init();

    //let simplepie handle the content type (atom, RSS…)
    $feedSmashing->handle_content_type();

    //grab the feed
    $feedNPR = new SimplePie();
    $feedNPR->set_feed_url(array(
    ‘http://www.npr.org/rss/rss.php?id=1001′,
    ));

    $feedNPR->set_item_limit(3);

    //enable caching
    $feedNPR->enable_cache(true);

    //provide the caching folder
    $feedNPR->set_cache_location(‘cache’);

    //set the amount of seconds you want to cache the feed
    $feedNPR->set_cache_duration(1800);

    //init the process
    $feedNPR->init();

    //let simplepie handle the content type (atom, RSS…)
    $feedNPR->handle_content_type();
    ?>

    Politico

    < ?php if ($feedPolitico->error): ?>

    < ?php echo $feedPolitico->error; ?>

    < ?php endif; ?>
    < ?php foreach ($feedPolitico->get_items() as $item): ?>

    Smashing Magazine

    < ?php if ($feedSmashing->error): ?>

    < ?php echo $feedSmashing->error; ?>

    < ?php endif; ?>
    < ?php foreach ($feedSmashing->get_items() as $item): ?>

    NPR

    < ?php if ($feedNPR->error): ?>

    < ?php echo $feedNPR->error; ?>

    < ?php endif; ?>
    < ?php foreach ($feedNPR->get_items() as $item): ?>

    # May 17, 2010 at 9:29 am

    Never used simplepie before, but the problem with the code you have posted is you aren’t ending your foreach loops (stick endforeach; where you want each to end.) Obviously I don’t know exactly what you are trying to achieve, but shouldn’t the loops be inside the ul? So you have one list with lots of items rather than lots of lists with one item each?

    # May 17, 2010 at 9:55 am

    As Tcooper says, I’m guessing you aren’t closing something and are getting an ‘Unexpected End’ error on your file. Showing us the error message would help though…

    # May 17, 2010 at 10:24 am

    Now I’m getting these errors:

    Quote:
    Warning: cache/5b60105eb4ce277db99d436af8b812b9.spc is not writeable in http://website.com/testmu/wp-content/th … plepie.inc on line 1773

    Warning: cache/570cbd2a6f5e3c8d32b539d47fb9dc41.spc is not writeable in http://website.com/testmu/wp-content/th … plepie.inc on line 1668

    Warning: cache/4f00777ba735f7a90601c8c02fadd110.spc is not writeable in http://website.com/testmu/wp-content/th … plepie.inc on line 1773

    Is this a permission error?

    # May 17, 2010 at 11:51 am

    Googling your error comes up with this http://simplepie.org/support/viewtopic.php?id=1135

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".