Aug
28
Posted on 28-08-2006
Filed Under (Wordpress , RSS/Atom , Syndication , Plugins ) by jay

It’s all about syndication. Today I have gathered some Wordpress Plugins the aid in consuming and producing RSS Feeds that I have found useful.

  • InlineFeed
    This lets you display RSS feeds in your Wordpress posts and pages. It’s very easy to use and you can see it in action here.
  • CompleteRSS
    This removes the ‘content:encoded’ tags from your XML feed which can help if your using an off-line blog manager like Drivel.
(0) Comments    Read More   
Aug
22
Posted on 22-08-2006
Filed Under (General , Rants , RSS/Atom ) by jay

At some point durring the day I derailed my thought process and ended up on amazon looking for books on Atom - (dev site: Atom or Wikipedia: Atom).
Developing Feeds with Rss and Atom
Essentially Atom is the next version of RSS and I’m just trying to see what’s ahead in technology.

(0) Comments    Read More   
Aug
02
Posted on 02-08-2006
Filed Under (PHP , RSS/Atom ) by jay

This ran on ScratchProjects.com for the article contest back in August2006.

Description: This HOWTO will explain how to extend Building an Ajax & PHP RSS Reader using AjaxAgent Part 1 to include No-Refresh/No-Post-Back Form operations, database interaction as well as auto-complete functions that demonstrate some advanced Ajax/PHP operations. The end result will be an RSS Feed Reader that contains the typical Create, Read, Update and Delete database operations but using Ajax to perform these tasks.

Note
Before diving in I must point out the PHP/MySQL code is not optimized for performance and the application contains NO SECURITY features what-so-ever. Also there are much better RSS Feed Readers out there but my intention is to show you some cool stuff you can do with Ajax, PHP and databases.
Setting Things Up

In Part 1 we learned how to consume some hard-coded RSS feeds and display them in a webpage. This will still be our end result but instead of having the URL's hard-coded we are going to gather them from a database.

Before we get started you'll need to:

1. Create a MySQL Database (or some place to add a new table)
2. Create a new table named Feeds

Once you've got the DB set up create the db connection file: dbconn.inc.php

PHP:

CODE:
  1. <?php   
  2.     $dbHost = "localhost";
  3.     $dbUser = "root";
  4.     $dbPwd ="root";
  5.     $dbName ="RSSDB";
  6. ?>

Agent Feeder Table Structure
AgentFeeder_SQL
SQL:
--
-- Table structure for table 'Feeds'
--

CODE:
  1. CREATE TABLE 'Feeds' (
  2.   'FeedID' bigint(11) NOT NULL AUTO_INCREMENT,
  3.   'FeedName' varchar(50) NOT NULL DEFAULT '',
  4.   'FeedURL' varchar(255) NOT NULL DEFAULT '',
  5.   'FeedCat' varchar(50) DEFAULT '0',
  6.   'FeedDateTime' datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  7.   PRIMARY KEY  ('FeedID')
  8. ) TYPE=MyISAM AUTO_INCREMENT=22 ;

Now that that's all set here's what we're going to do:

1. Create a Feed in the DB using a Ajax Enabled Form
2. Read all of the feeds to populate a list
3. Select a feed to read the RSS data
4. Update an existing feed using a Ajax Enabled Form
5. Delete an existing feed using a Ajax Enabled Form

Each step is a 3 part process: 1) HTML, PHP and Ajax.

(0) Comments    Read More   
Jul
26
Posted on 26-07-2006
Filed Under (PHP , RSS/Atom ) by jay

This ran on ScratchProjects.com for the article contest back in July 2006.

Description: This HOWTO will explain how to build an RSS Feed Reader using AjaxAgent and PHP that can read the latest posts from multiple Wordpress Blogs.

1. RSS Feed Reader using Ajax and PHP Part 1

Introduction

In this HOWTO I will explain how to build an RSS Feed Reader using AjaxAgent and PHP that can read the latest posts from multiple Wordpress Blogs.

I have my own domain name of gotfoo.org and since I tend to write about many subjects I felt that it was important to use sub-domains to seperate the content. I did this in the style of slashdot.org so I have linux.gotfoo.org and you.gotfoo.org. This setup works fine but I still want to just give out the root domain gotfoo.org for any shameless plugs and what not.

For my "homepage" I wanted to have a the latest posts with a link directly to the content but I did not want to have to hack Wordpress and make a database call or anything. Instead I wanted to hook into the existing RSS feed that is provided by the WP framework.

To start with I created an index.php in my root directory which would serve as the entry point to gotfoo.org and a subfolder named ajaxrss where I placed the ajaxagent RSS file:

* agent.php
* rss.php
* footer.php
* rss_cache.inc
* rss_fetch.inc
* rss_parse.inc
* rss_utils.inc

I haven't inspected all of these files but they work fine so I will focus on the 2 you need to be concerned about.

The agent.php is the main file for ajaxagent where all of the magic happens. This file can be anywhere on your server if you are using more than one of it functions.

The second file rss.php is where you are going to send the URL Feed to be processed.

The function rss get the url and then replaces any white space with "+" to make it url friendly and then it invokes fetch_rss with the url and returns a php list with the rss data, the stats, and any messages. Next it creates an string variable that will contain the rss feed as formatted html. It then creates the $title and $link variables and populates them with the corresponding rss data. Once it has some data it creates a link to the channel it got the rss feed from and inserts the link into the html, then it loops over each item in the the rss feed and adds it as a list-item link. Once it reaches the end of the loop it return the formatted html string back to the calling function.

Here is rss.php w/o comments:

CODE:
  1. <?
  2. require('rss_fetch.inc');
  3.  
  4. function rss($url)
  5. {
  6.   $url = str_replace(" ", "+", $url);
  7.   list( $rss, $status, $msg) = fetch_rss( $url );
  8.  
  9.     $html .=  "<ul>";
  10.  
  11.     $title = $rss->channel['title'];
  12.     $link = $rss->channel['link'];
  13.    
  14.     $html .=   "<h3><a href=$link>$title</a></h3>";
  15.  
  16.     foreach ($rss->items as $item ) {
  17.         $html .=   "<li>";
  18.         $html .=   "<a href=$item[link]>";
  19.         $html .=   $item[title];
  20.         $html .=   "</a></li>";
  21.     }       
  22.     $html .=   "</ul>";
  23.   return $html;
  24. }
  25. ?>

You shouldn't need to alter the rss.php file to get this working but if you want to include any other rss data like the description of each feed item or the date you would add it to the foreach loop.

For example if we wanted to include the description of each feed item we would add this $html .= $item[description]; to the foreach loop:

CODE:
  1. foreach ($rss->items as $item ) {
  2.     $html .=   "<li>";
  3.     $html .=   "<a href=$item[link]>";
  4.     $html .=   $item[title];
  5.     $html .=   "</a><br>";
  6.     $html .=   $item[description];
  7.     $html .=   "</li>";
  8. }

To get all of this working all you need to do is add the includes for rss.php and agent.php and the initilize the ajaxagent:

CODE:
  1. <?php
  2.   include "ajaxrss/rss.php";
  3.  
  4.   include_once("ajaxrss/agent.php");
  5. ?>
  6.  
  7. <?php
  8.   $agent->init();
  9. ?>

The add some JavaScript which calls the call_rss and the callback_rss functions and then I create a window.onload function that invokes call_rss w/ a URL to the rss feed:

CODE:
  1. <script type="text/javascript">
  2.  
  3.     function call_rss(rssURL) {   
  4.         agent.call('','rss','callback_rss',rssURL);
  5.       }
  6.  
  7.       function callback_rss(str) {   
  8.         var temp = document.getElementById('div_rss').innerHTML;
  9.         document.getElementById('div_rss').innerHTML = str + temp;
  10.       }
  11.  
  12.     window.onload=function(){
  13.  
  14.     call_rss('http://you.gotfoo.org/feed/');
  15.     call_rss('http://linux.gotfoo.org/feed/');
  16.  
  17. }
  18. </script>

In my Wordpress set up I am using permalink so all of my posts show up as a directory and not a file name or linux.gotfoo.org/?p=123.

Then add a DIV to place RSS Feed results in:

CODE:
  1. <div id='div_rss'></div>

and that's it.

It is important to note that the data is bound to the controls via the ID's. So you'll need to be sure that the DIV you are populating is named div_rss.

Now when the page loads it fetches the first 10 posts from linux.gotfoo.org and you.gotfoo.org.

This can easily be used to fetch posts from any RSS feed not just from Wordpress...

(0) Comments    Read More