Welcome Guest, Not a member yet? Register   Sign In
2 rss feeds
#1

[eluser]karloff[/eluser]
I'm trying to incorparate 2 rss feeds with the rss parser from the wiki.

However I can't get the second feed retrieved? Can some tell me what is the best way to do it, or what i'm doing wrong

controller
Code:
//Load the shiny new rssparse
          $this->load->library('RSSParser', array('url' => 'http://ws.audioscrobbler.com/1.0/user/junkie_scum/recenttracks.rss', 'life' => 0));
        //Get six items from the feed
          $lastfm = $this->rssparser->getFeed(6);
        
        //Load the shiny new rssparse
          $this->load->library('RSSParser', array('url' => 'http://feeds.delicious.com/rss/theblackcat', 'life' => 0));
        //Get six items from the feed
          $delicious = $this->rssparser->getFeed(6);

view
Code:
<ul class="rss">
&lt;? foreach ($lastfm as $item) :
    echo "<li>";
    echo '<a href=" '.$item['link'].'">';
    echo $item['title'];
    echo "</a>";
    echo "</li>";

  endforeach;  ?&gt;
  </ul>
      <h2>Delicious</h2>
     <ul class="rss">
&lt;? foreach ($delicious as $item2) :
    echo "<li>";
    echo '<a href=" '.$item2['link'].'">';
    echo $item2['title'];
    echo "</a>";
    echo "</li>";

  endforeach;  ?&gt;
  </ul>
#2

[eluser]karloff[/eluser]
nobody?
#3

[eluser]Pascal Kriete[/eluser]
The loader is a singleton interface. Basically means that reloading a library doesn't create a new object, but returns an existing one. Two options:
Code:
// Create a new instance
$delicious = new RSSParser($params);

// Reuse the old one - be careful this will break lastfm - make sure you're done using that one or use method 1
$this->feed_uri = 'http://feeds.delicious.com/rss/theblackcat';
$delicious = $this->rssparser->getFeed(6);
#4

[eluser]karloff[/eluser]
thanks for the reply, i'm not sure how you o about setting the new instance? could you explain further. what are the $params and how should i set the new feed?

thanks
#5

[eluser]Pascal Kriete[/eluser]
Have you done object oriented programming before karloff?

Both of the examples I have given should be functional as is. I used $params for the parameter array for the sake of brevity.
Code:
$params = array('url' => 'http://ws.audioscrobbler.com/1.0/user/junkie_scum/recenttracks.rss', 'life' => 0);
$delicious = new RSSParser($params);
#6

[eluser]karloff[/eluser]
no i haven't, it is on the long list to learn thoSmile

I have tried that and it seems not too work.

I set up a test page and the feed is not responding even by itself. any idea why?




Theme © iAndrew 2016 - Forum software by © MyBB