Sample code wanted Rss Feed

Hi all,

I have been looking for a long time now for some sample code for an rss feed in either, JQTouch, JQuery Mobile or Sencha Touch.

The sample code must have a thumbnail, title and short description and link to the main feed.

I've done a lot of googling an cannot find anything so I thought I might try here.

Hope someone can help

Thanks
error77Asked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
OK, that seems reasonable.  Not sure what you have tried, but you may want to adjust your expectations about RSS.  The publisher of the RSS feed decides whether to show a thumbnail image or not.  In the examples at the BBC site, they are not using the RSS format -- they are using Atom and it has a different tag set.  Make a Google search for "atom reader" and you may have better luck.
0
 
error77Author Commented:
Thanks for the links ...

1st link ... how do I use it?  Inside a html file? Not sure on how to test it.

2nd link ... I would need an example that has a thumbnail to as requested please.

I DID say it was hard to find :o)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
error77Author Commented:
Anyone please?
0
 
Gurvinder Pal SinghCommented:
if you can tell me the exact requirement, i can try to create an example for you
0
 
error77Author Commented:
Well, the layout / content I'm looking for is something like this image here:

http://i.telegraph.co.uk/multimedia/archive/01377/yahoophone_1377332f.jpg

Where, you get the Thumb, the title and a short desc ...then you can just go to the full story or full desc?

You know what I mean?

Thanks a lot

0
 
error77Author Commented:
Can anyone help please?
0
 
error77Author Commented:
Anyone?
0
 
DotNetChanoCommented:
if you can find a way to include the thumbnail this one might work

http://thefeedtool.com/
0
 
error77Author Commented:
I need it with the thumbs sorry.
0
 
Ray PaseurCommented:
RSS is a specialized subset of XML - just a limited set of predefined tags.  Information on RSS is available here:
http://cyber.law.harvard.edu/rss/rss.html

As you can see, once you know where the information comes from, it is pretty easy to populate the RSS XML string with data fields, including the URL of the thumbnail image.  Please tell us about the data source and we can show you how it might be integrated into the RSS XML string.
0
 
error77Author Commented:
Well, as far as rss feeds go any of the ones here will do : http://www.bbc.co.uk/news/10628494. I hope this helps.

Thanks
0
 
error77Author Commented:
I found some code that works but just needs a thumbnail field added to it. Would that be very hard to do?

Here is the link:

http://superdit.com/2010/12/18/building-rss-reader-with-sencha-touch-and-php/

thanks


0
 
Ray PaseurCommented:
I looked around and found an old example of an RSS generator that I have used in other web sites.  Follow the logic watching for variables named starting with $image and you can see how it is done.  Note that the <image> tag is part of the <channel>.

This RSS generator simply produces a new RSS feed whenever the contents of a directory changes.  The client that used this did all their online publishing by uploading PDF files into the "news" directory on their site.

HTH, ~Ray
<?php // RAY_rss_generator.php

// A CUSTOMIZABLE RSS GENERATOR TO NOTIFY YOU OF CHANGES TO A 'news' DIRECTORY
// RUN THIS MODULE AS A CRON JOB
// IT EXAMINES THE CONTENTS OF ITS DIRECTORY AND CHECKS FOR CHANGES
// IF THE DIRECTORY HAS CHANGED, IT POSTS A NEW RSS XML FILE
//
// IN THE 'index.php' PAGE OF THE 'news' DIRECTORY, YOU WANT TO HAVE SOMETHING
// LIKE THIS, SO PEOPLE CAN SUBSCRIBE TO THE RSS FEED
// <p><a href="rss_feed.xml">This RSS feed is updated whenever there is news!</a></p>



// DATA FIELDS FOR THE RSS FEED XML (IMAGE VARIABLES ARE OPTIONAL - DELETE IF NOT NEEDED)
$pubDate             = date('D, d M Y H:i:s T');

$channel_title       = "Your Web Site Name";
$channel_link        = "http://www.Your.org/";
$channel_description = "Your Company makes purple widgets.";

$image_url           = 'http://www.Your.org/images/your_rss_logo.png';
$image_title         = 'Your Web Site';
$image_link          = $channel_link;

$item_title          = "Your Web Site Name -- News Updated on $pubDate!";
$item_link           = "http://www.Your.org/news/";
$item_description    = "The RSS Feed from www.Your.org has been updated.";

// FILE NAMES FOR THE CHECKSUM AND RSS FEED (MUST START 'rss_')
$rss_check_file      = 'rss_checksum.txt';
$rss_feed_file       = 'rss_feed.xml';

// OPTIONAL EMAIL ADDRESS FOR DIRECT NOTIFICATION
$email_address       = 'You@Your.org';


/* ************************************************************************* */
function dir_list($dir)
{
    if ($dir[strlen($dir)-1] != '/') $dir .= '/';
    if (!is_dir($dir)) { return array(); }

    $dir_handle  = opendir($dir);
    $dir_objects = array();
    while ($obj  = readdir($dir_handle))
    {
        if (!in_array($obj, array('.','..')))
        {
            $filename    = $dir . $obj;
            $file_object = array (
                'name' => $obj,
                'size' => filesize($filename),
                'type' => filetype($filename),
                'time' => date("Y-m-d H:i:s", filemtime($filename))
            );
            $dir_objects[] = $file_object;
        }
    }
return $dir_objects;
}
/* ************************************************************************* */

/* ************************************************************************* */
function make_rss()
{
    global  $channel_title, $channel_link,  $channel_description;
    global  $image_title,   $image_link,    $image_url;
    global  $item_title,    $item_link,     $item_description;
    global  $pubDate;

    $rss_data = '';

    $rss_data    .= '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n";
    $rss_data    .= '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss">' . "\n";
    $rss_data    .= "<!-- -->\n<!-- -->\n";
    $rss_data    .= "<!--     IF YOU CAN SEE THIS, YOU NEED AN RSS READER!   -->\n<!-- -->\n<!-- -->\n";

    $rss_data    .= "<channel>\n";
    $rss_data    .= "<title>$channel_title</title>\n";
    $rss_data    .= "<link>$channel_link</link>\n";
    $rss_data    .= "<description>$channel_description</description>\n";
    $rss_data    .= "<language>en-us</language>\n";
    $rss_data    .= "<pubDate>$pubDate</pubDate>\n";

    // IMAGE DATA IS OPTIONAL
    $image_data    = $image_title . $image_link . $image_url;
    if ($image_data != '')
    {
        $rss_data .= "<image>\n";
        $rss_data .= "<url>$image_url</url>\n";
        $rss_data .= "<title>$image_title</title>\n";
        $rss_data .= "<link>$image_link</link>\n";
        $rss_data .= "</image>\n";
    }

    $rss_data    .= "<item>\n";
    $rss_data    .= "<title>$item_title</title>\n";
    $rss_data    .= "<link>$item_link</link>\n";
    $rss_data    .= "<description>$item_description</description>\n";
    $rss_data    .= "<pubDate>$pubDate</pubDate>\n";
    $rss_data    .= "</item>\n";

    $rss_data    .= "</channel>\n";
    $rss_data    .= "</rss>\n";

return $rss_data;
}
/* ************************************************************************* */


$dir            = getcwd();
$my_dir_list    = dir_list($dir);

// EXCLUDE THIS SCRIPT, THE XML, AND THE CHECKSUM FILE (ANYTHING STARTING WITH 'rss_')
$kount = 0;
foreach ($my_dir_list as $file_object)
{
    if (substr($file_object["name"],0,4) == 'rss_')
    {
        unset($my_dir_list["$kount"]);
    }
    $kount++;
}
$my_dir_list    = array_values($my_dir_list);

// IF MD5 FILES MATCH, THERE HAVE BEEN NO CHANGES SINCE LAST CHECK
$my_test_string    = md5(serialize($my_dir_list));
$my_base_string    = @file_get_contents($rss_check_file);
if ($my_test_string == $my_base_string) { die(); }

// WRITE THE NEW MD5 FILE AND WRITE THE NEW XML FOR THE RSS FEED
$kount        = file_put_contents($rss_check_file, $my_test_string);
$rss_text    = make_rss();
$kount        = file_put_contents($rss_feed_file, $rss_text);
if ($email_address != '')
{
    $uri    = $_SERVER["REQUEST_URI"];
    $uridir = substr($uri,0,strrpos($uri,'/'));
    $url    = $_SERVER["HTTP_HOST"] . $uridir . '/';
    mail($email_address, "Updated: $url", "$url");
}
die();

Open in new window

0
 
error77Author Commented:
Hi ray, i ran the code and tried to view it via the browser but no output shown.
0
 
Ray PaseurCommented:
Did you run exactly what I posted or did you adapt the code to your particular needs?  The latter would probably work; the former will not - I do not have your web site information.  Only you can provide that.  Mainly it was intended to show you how the <image> tag fits into the scheme of RSS.
0
 
error77Author Commented:
What I don't understand is that for example: http://www.bbc.co.uk/news/10628494 already has all the data on XML, why generate a new one? I just need the viewer part don't I ?
0
 
Ray PaseurCommented:
Maybe I am misunderstanding something.  Do you want to publish an RSS feed, or consume an RSS feed?  Please help clarify what you are trying to do, thanks.
0
 
error77Author Commented:
I want an RSS Viewer script that displays thumbnail too. All the ones I've found just display, Title and description.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.