iheartquotes provides an interface for easily pulling a random quote from a database of Unix fortune files. If all you want is the data then you should go find the fortune files (try freshmeat). If what you want is to easily put a dynamic quote on your webpage or in your login script then read on.
Put this in your .bash_profile or other login startup script. This will retrieve a random fortune from the iheartquotes server or quickly timeout if you're not online. OSX users will probably want to substitute 'curl --max-time 3' for the wget command.
alias getfortune='wget --timeout=3 -O - -q' alias fortune='getfortune http://www.iheartquotes.com/api/v1/random' alias myfortune='getfortune http://www.iheartquotes.com/api/v1/random?source=joel_on_software+paul_graham+prog_style myfortune
Cut and paste this HTML into your website. There's an example of what it looks like on my blog.
<iframe width="230" height="165" frameborder="0" scrolling="no" src="http://iheartquotes.com/api/v1/random?format=html&max_lines=4&max_characters=320&width=225&height=165"> <a href="http://iheartquotes.com/fortune/random">Random Quote</a> </iframe>
I put this code in the sidebar of my blog.
The API has a single REST method. Call the URI below to access the API and pass in any of the options as query string parameters.
format: return the result 'text', 'html', or 'json' format. The default is text.
max_lines: maximum number of lines in the quote.
min_lines: minimum number of lines in the quote.
max_characters: maximum number of characters in the quote.
min_characters: minimum number of characters in the quote.
source: pulls quotes from one of the sources listed. Multiple sources should be space or "+" separated, ex: calvin+xfiles
show_permalink: show the quote's permalink at the bottom of the text by default. Turn this off with "false" or "0".
show_source: show the quote's source at the bottom of the text by default. Turn this off with "false" or "0".
font_family:Render the text in the specified font-family.
font_color: Render the text in the specified font color.
width: The width of the box to render the quote in.
height: The height of the box to render the quote in.