TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-11-2009, 10:19 PM   #1 (permalink)
The Contributor
 
marxx's Avatar
 
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
marxx is on a distinguished road
Default RSS Parsing + multiple feeds??

Hi all!

I have this problem about RSS parsing and multiple feeds..

I want to get feeds from several place and show them in one feed stream.. You can see example in here (google feed API whit javascript).

Script what I have being using is lastRSS and I have managed to get feeds showing but not in same stream.. Is there way to get it done via lastRSS script or should I try other one instead?

Could saving feeds info into database be one way??

Thanks for all help and hints!! :)


Ps. below is some example of this lastRSS script what I'm using, could there be something??

Code:
<?php

function ShowOneRSS($url) {
    global $rss;
    if ($rs = $rss->get($url)) {

            echo "<ul>\n";
            foreach ($rs['items'] as $item) {
                echo "\t<li><a href=\"$item[link]\">$item[title]</a> - <small><a href=\"$rs[link]\">$rs[title]</a></small></li>\n";
            }
            echo "</ul>\n";
    }
    else {
        echo "Sorry: It's not possible to reach RSS file $url\n<br />";
        // you will probably hide this message in a live version
    }
} 

// include lastRSS
include "./lastRSS.php";

$rssall = array('http://applereviews.com/feed/',
                'http://www.datacenterknowledge.com/feed/',
                'http://feeds.feedburner.com/Woork');

// Create lastRSS object
$rss = new lastRSS;

// Set cache dir and cache time limit (1200 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = './temp';
$rss->cache_time = 1200;
$rss->cp = 'UTF-8';
$rss->items_limit = 5;

foreach ($rssall as $url) {
    ShowOneRSS($url);
} 
?>
Send a message via MSN to marxx
marxx is offline  
Reply With Quote
Old 06-12-2009, 04:25 AM   #2 (permalink)
The Contributor
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 36
Thanks: 2
jcorradino is on a distinguished road
Default

this is untested, but it should work (or at least get you closer to where you need to be). I set it up to use an output buffer to decide whether or not to display the list tags, and then to display them around everything else, making it look like one workflow.

Please let me know if I am way off base here, I may have misunderstood what you are looking for.

PHP Code:
<?php

function ShowOneRSS($url) {
    global 
$rss;
    if (
$rs $rss->get($url)) {
            foreach (
$rs['items'] as $item) {
                echo 
"\t<li><a href=\"$item[link]\">$item[title]</a> - <small><a href=\"$rs[link]\">$rs[title]</a></small></li>\n";
            }
    }


// include lastRSS
include "./lastRSS.php";

$rssall = array('http://applereviews.com/feed/',
                
'http://www.datacenterknowledge.com/feed/',
                
'http://feeds.feedburner.com/Woork');

// Create lastRSS object
$rss = new lastRSS;

// Set cache dir and cache time limit (1200 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir './temp';
$rss->cache_time 1200;
$rss->cp 'UTF-8';
$rss->items_limit 5;

ob_start();
foreach (
$rssall as $url) {
    
ShowOneRSS($url);

$buffer ob_get_contents();
ob_end_clean();

if (
$buffer!="") {
    echo 
"<ul>\n";
    echo 
$buffer;
    echo 
"</ul>\n";
} else {
    echo 
"There was a problem fetching RSS feeds."
}
?>
__________________
Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.
jcorradino is offline  
Reply With Quote
Old 06-12-2009, 06:22 AM   #3 (permalink)
The Contributor
 
marxx's Avatar
 
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
marxx is on a distinguished road
Default

Yey, Thank you jcorradino!! :)

This is what I was looking for and it worked like a charm! Well, third last line, the echo statement was missing ";" but who's counting?? ;)

Actually there is one more question.. lastRSS script can fetch pubDate from feed, is it possible to sort those feeds as date?

In ShowOneRSS function where is foreach, it fetch 'items' ($item[link], $item[title] ... ) and publish date would be $item[pubDate].. I have trying to find somekind of foreach sorting but I don't know is it possible.
But if you or someone else find a way, please let me know! :)


Thanks again!
Send a message via MSN to marxx
marxx is offline  
Reply With Quote
Old 06-12-2009, 02:12 PM   #4 (permalink)
The Contributor
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 36
Thanks: 2
jcorradino is on a distinguished road
Default

you could most likely print_r($rs) to see what exactly is being set. So like this:

PHP Code:
<?php

function ShowOneRSS($url) {
    global 
$rss;
    if (
$rs $rss->get($url)) {
            
print_r($rs);
    }


// include lastRSS
include "./lastRSS.php";

$rssall = array('http://applereviews.com/feed/',
                
'http://www.datacenterknowledge.com/feed/',
                
'http://feeds.feedburner.com/Woork');

// Create lastRSS object
$rss = new lastRSS;

// Set cache dir and cache time limit (1200 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir './temp';
$rss->cache_time 1200;
$rss->cp 'UTF-8';
$rss->items_limit 5;

foreach (
$rssall as $url) {
    
ShowOneRSS($url);
}
?>
(note: this is a little hacked together, and like before, isnt tested, but it should get you close to what you need to do)
__________________
Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.
jcorradino is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Mail - Help sending multiple attachments xperience Absolute Beginners 5 09-06-2010 08:27 AM
Passing multiple arguments to a function via one variable. delayedinsanity Advanced PHP Programming 10 05-07-2008 05:04 AM
Storing multiple file paths inside a database Orc General 10 02-17-2008 04:29 AM
Multiple Servers? Sam Granger Advanced PHP Programming 5 02-08-2008 03:14 PM
RSS Feeds mike.fro News and Announcements 1 02-20-2007 10:47 PM


All times are GMT. The time now is 02:00 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design