PDA

View Full Version : Help with the Pausing RSS Scroller



leematthews
05-24-2007, 03:19 AM
If anyone doesn't know what I'm talking about, refer here:
http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/

Anyway...the RSS feed page that I am trying to get to work is hosted by myself but "powered" by blogger.com. Here is the site:
http://www.matthewdlee.com/blog/atom.xml
(Note: I added a whole bunch of tests posts not to be taken seriously)

In the demo.htm I have this in the BODY:

<script type="text/javascript">

//new rsspausescroller(RSS_id, divId, divClass, delay, linktarget, optionalswitch)
//1) RSS_id: "Array key of RSS feed in scrollerbridge.php script"
//2) divId: "ID of DIV to display ticker in. DIV is dynamically created"
//3) divClass: "Class name of this ticker, for styling purposes"
//4) delay: delay between message change, in milliseconds
//5) linktarget: Target of links inside RSS feed. Set to "" for current page.
//6) optionalswitch: "optional arbitrary" string to create additional logic for formatrssmessage() to use.
// By default, optionalswitch supports "date", or "date+description" to also show these parts of a RSS feed.


new rsspausescroller("blog", "pscroller2", "rssclass", 3000, "", "date+description")

</script>

The rsspausescroller.js is set up properly (I think). I didn't change its location when I downloaded and uploaded it.

For the scrollerbridge.php:


<?php

/*
======================================================================
Pausing RSS Scroller bridge script
Author: Dynamic Drive (http://www.dynamicdrive.com)
Created: March 16th, 2006.
Function: Converts requested RSS feed from lastRSS into JavaScript array
======================================================================
*/

// include lastRSS
include "lastRSS.php"; //path to lastRSS.php on your server relative to scrollerbridge.php

// Create lastRSS object
$rss = new lastRSS;
$rss->cache_dir = 'cache'; //path to cache directory on your server relative to scrollerbridge.php. Chmod 777!
$rss->date_format = 'M d, Y g:i:s A'; //date format of RSS item. See PHP date() function for possible input.
$rss->cache_time = 1800; //Global cache time before fetching RSS feed again, in seconds.

// Define your list of RSS URLs- "RSS_id"=> "URL to RSS feed"
$rsslist=array(
"cnn" => "http://rss.cnn.com/rss/cnn_topstories.rss",
"bbc" => "http://www.matthewdlee.com/blog/atom.xml",
"news.com" => "http://news.com.com/2547-1_3-0-5.xml",
"slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
"dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new",
"kotaku" => "http://feeds.gawker.com/kotaku/excerpts.xml",
"kje" => "http://kingjamesedition.blogspot.com/feeds/posts/default",
);

//Domains that are authorized to display scroller:
//Seperate multiple domains each with a comma (",")
//For example: $allowedDomains="dynamicdrive.com, javascriptkit.com"
//OR enter a blank string to allow any domain (ie: for RSS feed syndication):
$allowedDomains="";

////Beginners don't need to configure past here////////////////////

Header("content-type: application/x-javascript");
$rssid=$_GET['id'];
$rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("rsscontentdata=\"Error: Can't find requested RSS in list.\"");
$divid=$_GET['divid']; //ID of DIV scroller

// -------------------------------------------------------------------
// checkdomains()- Checks that current site is authorized to display scroller
// -------------------------------------------------------------------

function checkdomains($allowed, $referral){
if ($allowed!=""){
$found=0;
$allowlist=split (",", $allowed);
foreach ($allowlist as $allow){
$allow=trim($allow);
$found+=strpos(" ".$referral, $allow);
}
if (!$found)
die("rsscontentdata=\"This domain isn't authorized to show scroller.\"");
}
}

@checkdomains($allowedDomains, $_SERVER["HTTP_REFERER"]); //check if domain is authorized to display scroller

// -------------------------------------------------------------------
// outputRSS_JS()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format
// -------------------------------------------------------------------

function outputRSS_JS($url, $divid) {
global $rss;
if ($rs = $rss->get($url)){
echo "rsscontentdata.$divid=new Array();\n";
$i=0;
foreach ($rs['items'] as $item) {
echo "rsscontentdata.$divid" . "[$i]={link:\"" . slashit($item[link]) . "\", title:\"" . slashit($item[title]) . "\", description:\"" . slashit($item[description]) . "\", date:\"" . slashit($item[pubDate]) . "\"}\n";
$i++;
}
if ($rs['items_count'] <= 0) { echo "rsscontentdata=\"Sorry, no items found in the RSS file\""; }
}
else {
echo "rsscontentdata=\"Sorry: It's not possible to reach RSS file $url\"";
// All else fails
}
}

function slashit($what){ //Encode text for storing in JavaScript array
$newstring=str_replace('&apos;', '\'', $what); //replace those half valid apostrophe entities with actual apostrophes
return rawurlencode($newstring);
}

// ===============================================================================

outputRSS_JS($rssurl, $divid);

?>

Basically I just added "blog"

I am not sure why its not working and whether its a problem I have with blogger.com's feed file (whenever I make a post I have to go to Blogger.com and it uploads via ftp). :confused:

If anyone can help, please do so!

djr33
05-24-2007, 03:26 AM
This should be posted in the proper forum, and has now been moved. Please also review the proper posting format.

leematthews
05-25-2007, 07:29 PM
bump...anyone? :confused: