Solved

Sample code wanted Rss Feed

Posted on 2011-03-23
19
2,822 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:error77
  • 11
  • 5
  • 2
  • +1
19 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35197382
0
 

Author Comment

by:error77
ID: 35197432
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
 

Author Comment

by:error77
ID: 35197863
Anyone please?
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35198789
if you can tell me the exact requirement, i can try to create an example for you
0
 

Author Comment

by:error77
ID: 35200716
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
 

Author Comment

by:error77
ID: 35203115
Can anyone help please?
0
 

Author Comment

by:error77
ID: 35219020
Anyone?
0
 
LVL 4

Expert Comment

by:DotNetChano
ID: 35220838
if you can find a way to include the thumbnail this one might work

http://thefeedtool.com/
0
 

Author Comment

by:error77
ID: 35221843
I need it with the thumbs sorry.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35224485
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
 

Author Comment

by:error77
ID: 35224957
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
 

Author Comment

by:error77
ID: 35225385
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35226124
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
 

Author Comment

by:error77
ID: 35227055
Hi ray, i ran the code and tried to view it via the browser but no output shown.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35227073
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
 

Author Comment

by:error77
ID: 35227303
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35227540
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
 

Author Comment

by:error77
ID: 35227867
I want an RSS Viewer script that displays thumbnail too. All the ones I've found just display, Title and description.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 35227944
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

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now