CDB cat dog-egories:
      

November 19, 2004

Note: CogDogBlog has a new WordPress powered home at http://cogdogblog.com/. All entries from this version have been moved there, so as a guide dog service try finding this article in its new home by title search.

Tasty del.icio.us feeds with PHP

Via open artifact cam this link to MovableBlog's Integrating del.icio.us with PHP and Magpie describing a way to embed the output of your del.icio.us links in a web page. As always, there are many paths to the same destination.

As frequent readers know, this can be achieved via the JavaScript approach using our Feed2JS service or standalone code. Of course there is a round trip delay for this as a PHP script must be called which then fetches a fresh feed from the source (or loads a cached one). Or maybe JavaScript is just too clumsy for your tastes,

If you are on a PHP capable server, you can install Magie (which you need to do with the approach described via MovableBlog), but if you also use our PHP version of Feed2JS you can achieve the same effect.

The advantage of our approach over the one described above is that it can be repeated quite easily just by creating new shorter series of include statements. For example, below I will use it with my del.ici.ous RSS feed, but 3 weeks ago I used a different set of parameters to the same code. Feed, Rinse, Repeat.

All I need to make a feed here is to use

<?php 
	// declare Feed2Js variables
	$src = 'http://del.icio.us/rss/cogdog';
	$chan = 'y';
	$num = 10;
	$desc = 1;
	$date = 'y';
	$targ = 'y';
	
	// include the feed2php include file
	include '/var/www/html/..../feed2php.inc';
?>

which gives us...


Warning: include(/var/www/html/feed/feed2php.inc) [function.include]: failed to open stream: No such file or directory in /home/cogdog/public_html/cogdogblog.com/alan/archives/2004/11/19/feed.php on line 217

Warning: include() [function.include]: Failed opening '/var/www/html/feed/feed2php.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cogdog/public_html/cogdogblog.com/alan/archives/2004/11/19/feed.php on line 217

And I can just as easily add another just as quickly, say may furl feed to the same page:

<?php 
	// declare Feed2Js variables
	$src = 'http://www.furl.net/members/cogdog/rss.xml';
	$chan = 'y';
	$num = 10;
	$desc = 1;
	$date = 'y';
	$targ = 'y';
	
	// include the feed2php include file
	include '/var/www/html/...../feed2php.inc';
?>

which gives us...


Warning: include(/var/www/html/feed/feed2php.inc) [function.include]: failed to open stream: No such file or directory in /home/cogdog/public_html/cogdogblog.com/alan/archives/2004/11/19/feed.php on line 251

Warning: include() [function.include]: Failed opening '/var/www/html/feed/feed2php.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cogdog/public_html/cogdogblog.com/alan/archives/2004/11/19/feed.php on line 251
blogged November 19, 2004 01:40 PM :: category [ rss ]
Comments About "Tasty del.icio.us feeds with PHP"
RSS Feed for comments on this entry
RSS Feed for all CDB comments
 

Alan - When I view the source of your feed2js created page, I am abale to see the HTML source. When I view the source of my feed2js created page, all I see is the SCRIPT tag - I don't see the result of the processing. What gives?

Commented by: Randy Brown on November 19, 2004 06:24 PM

 

Because the examples above are not generated by the JavaScript approach (which echos a series of document.write commands returned as a .js source file) but by direct include of php statements which output raw HTML to the page.

Commented by: Alan Levine on November 20, 2004 03:17 PM

 

After I did a little more looking, that's what I figured, Alan. You're using the .inc file.

Before I dig further: have you, or anyone, come up with a working method to include the .inc calls across a http request? To include the feeds in WebCT or Blackboard (servers not supporting PHP directly), we'll need to pass the requests to another PHP-friendly server.

I ask, as the Javascript version is not 508 accessible. The PHP .inc results can be. We need a way to fully write the contents of a feed back to a page that resides on a server not supporting PHP.

Commented by: Randy Brown on November 21, 2004 07:06 AM

 

Wow! Wow! Wow!

Alan, your Feed2js is supurb! I installed the stand alone on my server, following your clear instructions precisely and it works like a charm! Bravo!

One question though, what is the best way to include multiple feeds? Should I initiate a new script for each, or can I place multiple feeds within one instance of the javascript?

Thanks again. You're brilliant.

Commented by: Roch Smith on November 21, 2004 09:05 AM

 

I cannot see an easy way to include dynamic content into such pages-- you may have to look at something like server side includes which would require writing something completely new to do the parsing and dispaly of RSS content.

However, I am not sure about the statement of not being 508 compliant. The JavaScript is ignored, but Feed2JS includes a NOSCRIPT tag that links to an HTML generated version of the feed (thus not embedded in the page, but still available to the user).

Try turning off JS in your browser to see how it works.

Commented by: Alan Levine on November 21, 2004 09:09 AM

 

Roch,

Thanks- multiple insertions of feeds would require a separate Feed@JS chunk of cod eper page. This could be a hit on your time to load pages;l I have done as many as 3 and there is a lag for the content to load. Your mileage may vary.

If your server runs PHP, however, you can speed it up a bit by using the method described in this post, which has 2 different sets of feeds on the same page.

Commented by: Alan Levine on November 21, 2004 09:12 AM

Spammers Have Force Our Hands...
spamroach.jpg
Note: Those nasty blog-spamming roaches have forced us to take action to prevent their spread- all entries made to this blog will remain open for comments for 30 days after the original posting date. After that, it is old news anyhow, correct?

If you really need to make contact with the chief dog around here, please submit a request via our feedback center