homepage Welcome to WebmasterWorld Guest from 23.20.61.85
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
Forum Library, Charter, Moderators: bill & werty

RSS, ATOM, and Related Technologies Forum

    
Automagically Switching to RSS
I want a magic reroute to an RSS feed based on accept headers.
cmarshall

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 392 posted 1:14 am on Oct 26, 2005 (gmt 0)

Folks,

I use a smart index file to route cell phones that hit my main URI into WML and XHTML-MP pages. I'm wondering if I can do the same for RSS, based, maybe upon HTTP ACCEPT headers. I'll do a bit of experimenting, but I find that I often miss that one whacky browser that causes the whole thing to go pear-shaped.

I'd be interested in knowing if this is possible, and, if so, whether or not it is advisable.

Here's how the site works now:

If a standard browser hits it, then we go to the normal XHTML page.

If a cellphone hits it, then we head for WML. However, if the cell phone will accept XHTML-MP, it goes to the XHTML-MP page.

I would like to add an RSS aggregator to that list. That way, I don't have to have these annoying XML links that scare the bejeezus out of my visitors when their page goes blank or fills with fluent Martian.

Here's the code I use for the cell phone switch:


<?php
$http_accept = preg_split ( "/\s*\,\s*/", $_SERVER['HTTP_ACCEPT'] );

foreach ( $http_accept as $type )
{
$type = preg_replace ( "/\s+/","", $type );
$type = preg_replace ( "/\;.*$/","", $type );
$accept[$type] = true;
}

$language = 'xhtml';
$query = "";

if ( $_SERVER['QUERY_STRING'] )
{
$query = "?". urlencode ( $_SERVER['QUERY_STRING'] );
}

if ( $accept['text/vnd.wap.wml'] )
{
$language = 'wml';
if ( $accept['application/xhtml+xml'] )
{
$language = 'xhtml_mp';
}
}

if ( $language == 'wml' )
{
header ( "Location: wml.php$query" );
}
elseif ( $language == 'xhtml_mp' )
{
header ( "Location: xhtml_mp.php$query" );
}
else
{
header ( "Location: xhtml_home.php$query" );
}
?>

 

teaperson

10+ Year Member



 
Msg#: 392 posted 9:39 pm on Nov 7, 2005 (gmt 0)

One problem you'll run into is that there are a gazillion different RSS readers.

I personally think the best solution to not displaying hideous, confusing XML to users is to use an XSL stylesheet to render it as readable XML. This is what feedburner does. If you google xsl and rss, you'll get some good pointers.

cmarshall

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 392 posted 2:48 am on Nov 8, 2005 (gmt 0)

Thanks!

Wildu.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved