Advertisement:
A2Hosting

Author Topic: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds  (Read 456452 times)

Offline Oldiesmann

  • Lead Developer
  • SMF Super Hero
  • *
  • Posts: 23,887
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
One of the best features in SMF is its news feeds. However, many people aren't aware of how many options there are, or that this is even available. So, here's a list of available options and what they do...

First, make sure you've enabled the feeds:

Admin -> News and Newsletters -> Settings
Check the box next to "Enable XML/RSS News".
The "Maximum post length" value determines how many characters of a post are output in the feeds. The default value (255) is fine for now


Now, on to the fun stuff.

All of the XML content is accessed via the ".xml" action...
Other formats can be achieved by adding one of the following to the URL:
;type=atom - Atom
;type=rdf - RDF
;type=rss - RSS 0.91
;type=rss2 - RSS 2.0

The default feed is the 5 most recent posts:
http://www.simplemachines.org/community/index.php?action=.xml

There are several "sub-actions" available to this action, specifying exactly what to display:

Recent Posts (displays the most recent posts that you can see)
"Sub-action": recent
Default: Shows 5 most recent posts
Available options:
limit=x - display the "x" most recent posts (if number is less than 5, it will display 5. If number is larger than 255, it will display 255).
board=y - display only the recent posts from board "y"
boards=x,y,z - display only the recent posts from the specified boards
c=x or c=x,y,z - display only the recent posts from boards in the specified category/categories
Example: http://www.simplemachines.org/community/index.php?action=.xml;sa=recent;board=72;limit=10

News (displays the first post from the most recent topics that you can see)
"Sub-action": news
Available options:
limit=x - display only "x" items
board=y - display only news topics from board "y"
boards=x,y,z - display only news topics from the specified boards
c=x or c=x,y,z - display only news topics from boards in the specified category/categories
Example: http://www.simplemachines.org/community/index.php?action=.xml;sa=news;board=72;limit=10

Members (displays most recent members):
"Sub-action": members
Available options:
limit=x - display only the "x" most recent members
Example: http://www.simplemachines.org/community/index.php?action=.xml;sa=members;limit=10

Profile (displays the "profile summary" data in a nice XML feed for the specified user)
"Sub-action": profile
Required option:
u=x - display the profile info for user whose ID is "x"
Example: http://www.simplemachines.org/community/index.php?action=.xml;sa=profile;u=150

Now - you're probably wondering what you can do with this. Quite a bit actually.

You can syndicate this stuff by giving people these URLs to use on their sites (they will need to have their own RSS parser to deal with it though - CaRP is a good free one (requires PHP)). You can also use PHP's XML Parser Functions to format the output the way you want it (although you can also do this using SSI.php). There are also several free sites that will parse the feeds for you, including www.rss2javascript.com and www.feedburner.com.

You can also subscribe to these feeds through an XML reader, Firefox, Thunderbird or any other software that supports XML or RSS feeds (note - Outlook and Outlook Express do not support this...) - you will need to have either "type=rss" or "type=rss2" somewhere in the URL for it to work. If you would like to know how to set this up in Firefox or Thunderbird, let me know. Enjoy!

EDIT: Updated post to reflect options available in 1.1.
EDIT again: Fixed typo (";type=rss - RSS 2.0" -> ";type=rss2 - RSS 2.0" - thanks to Sarge for pointing that out)
« Last Edit: April 13, 2008, 01:30:38 AM by SleePy »

johnm

  • Guest
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #1 on: January 29, 2005, 06:51:31 AM »
thanks for that it really helped

and its so simple!


Offline bjp

  • Jr. Member
  • **
  • Posts: 163
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #2 on: February 03, 2005, 09:49:25 AM »
I have done what you say but i have tis erreor :

La page XML ne peut pas être affichée
Impossible d'afficher l'entrée XML en utilisant la feuille de style XSL. Corrigez l'erreur, puis cliquez sur le bouton Actualiser ou réessayez ultérieurement.


--------------------------------------------------------------------------------

I also ad this :
   // If RSS/XML news is enabled, indicate that an RSS feed is available
   if (!empty($modSettings['xmlnews_enable']))
      echo '
      <link rel="alternate" type="application/rss+xml" title="RSS" href="', $scripturl, '?type=rss;action=.xml;limit=20" />';

Référence à l'entité non définie 'agrave'. Erreur de traitement de la ressource http://www.forum-asie.com/smf/index.php?act...

  <time>29 Janvier 2005 &agrave; 16:37:11</time>
-------------------------^
 
http://www.forum-asie.com/smf/index.php?action=.xml;sa=members;limit=10
« Last Edit: February 03, 2005, 09:57:21 AM by bjp »

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #3 on: February 03, 2005, 03:25:33 PM »
Instead of using "&agrave;" in your time format, use the entity code - I don't remember what it is, off hand, though.

-[Unknown]

Offline Tangent

  • Newbie
  • *
  • Posts: 2
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #4 on: February 09, 2005, 02:36:43 AM »
Instead of resent posts is there a way to get the same results as "Show unread posts since last visit.". I can't just set action =unread which was my first thought. sa=unread gives me something different, seems that posts are grouped by thread. I'm not sure what sa is even though.

anyway help would be cool thanks.

Offline Oldiesmann

  • Lead Developer
  • SMF Super Hero
  • *
  • Posts: 23,887
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #5 on: February 10, 2005, 10:47:55 AM »
Currently there is no XML/RSS feed for unread posts. Sorry.

Offline inthe80s

  • Charter Member
  • Jr. Member
  • *
  • Posts: 166
  • Gender: Male
  • Pick a winner...
    • in the 00s
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #6 on: February 11, 2005, 12:46:42 PM »
I just tried this for the most recent posts by board, but I'm not getting any results.  When I tried the example above using this board, it only gives one post.  Though when I tried it on my system (without specifying a board number) it did appear to work correctly.

I actually want the most recently updated topics, not the posts themselves.  I guess I could do that by ignoring duplicate topics.  That is I actually got a response from the server for the appropriate board.
Running SMF since May '04.  Started with YaBB on Oct 2001.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #7 on: February 11, 2005, 06:23:33 PM »
Find, News.php:

Code: [Select]
WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 4 * $_GET['limit']) . "
Replace:

Code: [Select]
WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 40 * $_GET['limit']) . "
How do I modify files?

-[Unknown]
« Last Edit: March 03, 2005, 06:36:06 PM by [Unknown] »

Offline inthe80s

  • Charter Member
  • Jr. Member
  • *
  • Posts: 166
  • Gender: Male
  • Pick a winner...
    • in the 00s
Re: Getting the Most Out of SMF - XML, RSS and RSS2 (and Atom and RDF) feeds
« Reply #8 on: February 18, 2005, 12:25:14 PM »
Find, News.php:

Code: [Select]
WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 4 * $_GET['limit']) . "
Replace:

Code: [Select]
WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 40 * $_GET['limit']) . "
[[:How do I modify files?]]

-[Unknown]

that won't do it.  I was just looking the line of code over, and it appears to work by subtracting from the message id.  I upped it to 400 and then used the limit, and that seemed to get around it.


I looked over the source for the news.php file, and it doesn't really have the kind of functionality I want.  I'll play with it at some point, and maybe write a new function for returning the most recently updated threads instead of just the most recently updated posts.
Running SMF since May '04.  Started with YaBB on Oct 2001.

Offline Robinski

  • Newbie
  • *
  • Posts: 5
  • Gender: Male
  • I'm a llama!
is there a Way of requesting the RSS as a logged in user?

cause we have one board that is visible to all (where no one can post)
and the rest is only for authorised users

It would be nice to have somthing like
user=username
pass=password

to get info from all boards

Offline mytreo

  • Jr. Member
  • **
  • Posts: 284
    • treo
is there a Way of requesting the RSS as a logged in user?

Yes! If you use the live-bookmarks feature in Mozilla to get the feed then provided you're logged in it will use the stored cookie and you will see messages according to your user privileges.

* hugs Firefox *

BTW, thanks for the extra info Oldiesman, very very useful.
Treo forum - Powered by SMF, of course
Treo news - powered by MovableType and integrated with SMF
Treo downloads - hacked from phpNuke and integrated with SMF
Treo knowledge base - powered by Wikka and integrated with SMF
Treo 650 | Treo 700w | Treo 700p

Offline Robinski

  • Newbie
  • *
  • Posts: 5
  • Gender: Male
  • I'm a llama!
Ill try that one .. thanx

though it still would be nice if I could do something like user=... and pass=...
so I can use every RSS reader I wouldlike

Offline trikos

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
  • -
    • Martinus Forum
Thunderbird will not accept this one as a valid rss feed??

http://www.martinusforum.dk/forum/index.php?action=.xml;type=rss

It works with Firefox livebookmarks ???

Please help...

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
WFM?  Try rss2 instead of rss.

-[Unknown]

Offline trikos

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
  • -
    • Martinus Forum
I can get simplemachines.org feeds to work in thunderbird and my own feeds in firefox, but not my own feed in thunderbird. I just stick to the livebookmarks, so no problem. Just strange  8)

Offline DeadMetal

  • Jr. Member
  • **
  • Posts: 122
  • Gender: Male
Me and my moderators are interested in a RSS feed which only shows new topics: the first message of a new topic and the board. So they can respond quickly when they notice that it has been placed in the wrong board.

Could you create a RSS(2) feed for this purpose?


Offline eeyore

  • Newbie
  • *
  • Posts: 1
I`m just getting a bit confused with all this..... (lol)

Can you disply RSS feeds within a forum?

eg:
if i set up a news forum could you make it that the feed would apper under a new post ?

or do i have to set it up within the news box?

Some one mentioned using a site to convert it to java scrip.... where would i post the script?

cheers

Offline woehrl

  • Semi-Newbie
  • *
  • Posts: 18
what must i do so that i can loggin trough the link like: ;name=bla;pw=nice ? Cause I don't use Firefox to call for the news. And the login feature of the programm doesn't work

Offline Zenigata

  • Jr. Member
  • **
  • Posts: 237
  • Gender: Male
    • Il sito di Zenigata
http://forum.zenigata.it/index.php?action=.xml;limit=20;type=rss2

The action above displays the 20 most recent posts. Is there a way to display the 20 most recent topics?

Thanks.