Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: 1 2 [3]

Author Topic: [ADDON] Grab external feeds  (Read 21818 times)

lann

  • Newbie
  • *
  • Karma: 1
  • Posts: 17
Re: [ADDON] Grab external feeds
« Reply #30 on: February 19, 2009, 06:16:31 PM »

in external file - dont forget to add

<?php 

 $feed = new SimplePie('http://www...........com/search/rss.html?s=xxxxxx&l=xxxx&lid=xxxxxx');

?>

<?php foreach ($feed->get_items() as $item): ?>           


attention aux guillemets, si la page est en php il faut utiliser '   et non "
Logged

Sven

  • Dev Invitee
  • ULTIMATE member
  • *****
  • Karma: 88
  • Posts: 2069
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [ADDON] Grab external feeds
« Reply #31 on: February 19, 2009, 06:29:20 PM »

Salut les gars... c'est vraiment sympa de me donner un coup de main : c'est pour un pote que je cherche à mettre ça en place.

But for for all snoozers let's go on in english now.

Whatever I try I still get the same error:
Quote
Fatal error: Call to a member function get_permalink() on a non-object in D:\xampp\htdocs\richard\script.php on line 2

Im my index file I got:
Quote
<?php require 'php/simplepie.inc'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
bla bla bla
In the script:
Quote
<div class="header">
      <h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
      <p><?php echo $feed->get_description(); ?></p>
   </div>
 <?php
// We'll process this feed with all of the default options.
$feed = new SimplePie('http://simplepie.org/blog/feed/');
?>
   <?php
   /*
   Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop.
   */
   foreach ($feed->get_items() as $item):
   ?>
 
      <div class="item">
         <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
         <p><?php echo $item->get_description(); ?></p>
         <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
      </div>
 
<?php endforeach; ?>
I thought I could make it fingers in the nose as we say in France, but no way: whatever I try give the same result. :P

lann

  • Newbie
  • *
  • Karma: 1
  • Posts: 17
Re: [ADDON] Grab external feeds
« Reply #32 on: February 19, 2009, 06:42:24 PM »

I think you have parse error. your script must be simple text file (with html extention) and with 4 lines of code. For example as mine is
******************************************************************
<?php 

 $feed = new SimplePie('http://www.xxxx.com/xxxx/rss.html?s=xxxx&l=xxxxx&lid=1111111');

?>
                     
        <TABLE width="100%">
     
                        <TR>
                <TD><?php foreach ($feed->get_items() as $item):
   ?>           
                 
         <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
         <p><?php echo $item->get_description(); ?></p>
               
                </TD>
            </TR>
            <TR>
                <TD>
                          
    <?php endforeach; ?>
              
                </TD>
            </TR>
       
        </TABLE>
************************************************************
that's all. nothing else. Then in admin area, when creating a new file you make [include] your_text_file.html [/include]
Logged

bikoz

  • Jr. Member
  • **
  • Karma: 3
  • Posts: 66
Re: [ADDON] Grab external feeds
« Reply #33 on: February 19, 2009, 06:45:02 PM »

If I understand the error message, the error is NORMAL: the $feed object (instance) should be initialized first.

In other words, $feed = new SimplePie('http://simplepie.org/blog/feed/'); should appears BEFORE $feed->get_permalink(); and friends.

Try to rewrite your script and it should work.

If it works, try to move the include back in the script (instead of snews's index.php file).
Logged

bikoz

  • Jr. Member
  • **
  • Karma: 3
  • Posts: 66
Re: [ADDON] Grab external feeds
« Reply #34 on: February 19, 2009, 10:00:04 PM »

I've just tried this setup on my dev machine with the code from SimplePie's documentation (http://simplepie.org/wiki/setup/sample_page): it works like a charm, I confirm.

No need to modify index.php, the include statement can be in your custom PHP script (the one you call from your actual snews page). You just have to take care of the actual path of simplepie.inc. By the way, you don't have to put it in specific dir (like "php" in the documentation), it can live in the same dir (root) as index.php and snews.php, no worries.

For example I've put it in a "simplepie" dir and I've renamed it to simplepie.inc.php: it still works as expected.

Same thing for the 'cache' dir: by default it has to be in the same dir as your custom script, but this can be changed by editing simplepie.inc, line 490 (the path is relative to your custom script, not simplepie.inc itself because of the include statement).

The ball's in your court!  :-)
« Last Edit: February 19, 2009, 10:02:40 PM by bikoz »
Logged

Sven

  • Dev Invitee
  • ULTIMATE member
  • *****
  • Karma: 88
  • Posts: 2069
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [ADDON] Grab external feeds
« Reply #35 on: February 20, 2009, 07:40:18 AM »

Oh boys! You made my day!

Superb! Brilliant!
Magnifique !

Both of ya desserve a HUGE KARMA.

Garçon, s'il vous plaît : 1 Karma pour chacun de ces messieurs.
 8)

centered

  • Guest
Re: [ADDON] Grab external feeds
« Reply #36 on: February 22, 2009, 02:28:30 AM »

Surpisingly SmashingMagazine.com has a recent article with SimplePie

http://www.smashingmagazine.com/2009/02/20/ask-sm-css-smooth-page-scrolling-divs-of-equal-height-dealing-with-ie-6/




Code: [Select]
<?php

    
//get the simplepie library
    
require_once('inc/simplepie.inc');

    
//grab the feed
    
$feed = new SimplePie();

    
$feed->set_feed_url(array(
    
'http://feeds2.feedburner.com/CssTricks',
    
'http://smashingmagazine.com',
    ));

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

    
//provide the caching folder
    
$feed->set_cache_location('cache');

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

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

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

?>


Code: [Select]

<?php foreach ($feed->get_items() as $item): ?>

<div class="chunk">

<h4 style="background:url(<?php $feed $item->get_feed(); echo $feed->get_favicon(); ?>) no-repeat; text-indent: 25px; margin: 0 0 10px;"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>

<p class="footnote">Source: <a href="<?php $feed $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed $item->get_feed(); echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p>

</div>

<?php endforeach; ?>
Logged
Pages: 1 2 [3]