Contact Us

Alagad is located in Chapel Hill, North Carolina in the Research Triangle Park area.

Phone: 888-ALAGAD4
Fax: 888-248-7836
Email: please use our contact form

208 Calderon Dr.
Chapel Hill, NC 27516 USA

Request an Alagad proposal
Request a TaskForce consultation

Fortune Web Service

Quoth Wikipedia:

fortune is a simple program that displays a random message from a database of quotations. Most distributions of fortune are bundled with files of quotations from famous people, sayings like those found on fortune cookies (hence the name), and other humorous items. fortune is predominantly found on Unix-like systems, but clients for other platforms exist as well. Often, users on text-mode Unix terminals will place this command into either their .profile or .logout files to display them at logon and logout, respectively.

Fortune comes with many of the flavors of free Unix-like operating systems. The program simply picks a random string out of a set of text files and displays it. Frankly, I love Fortune.

To celebrate Fortune, I took it on myself to write a Web Service version in ColdFusion. It works quite similarly to the traditional executable version. If you're interested in how I built this, the source code can be downloaded using the link to the right.

Here's the Fortune Web Service WSDL: http://www.alagad.com/WebServices/fortune/fortune.cfc?wsdl

Please be aware that the fortunes returned by the Fortune Web Service do not reflect the views or opinions of Alagad or any Alagad employees.

The Fortune Web Service provides the following methods:

getTopicsList()

String getTopicsList()

The getTopicsList() method returns a comma delimited list of available topics. Currently the list is as follows:

sports, science, zippy, wisdom, kids, love, tao, platitudes, songspoems, calvin, programingstyle, education, simpsonschalkboard, food, asciiart, miscellaneous, simpsonshomer, literature, hitchhiker, cookie, dune, humorists, startrek, riddles, job, people, computers, news, law, art, pets, magic, goedel, definitions, medicine, fortunes, linuxcookie, drugs, ethnic, politics

I may add or remove topics in the future.

getTopicsArray()

Array getTopicsArray()

The getTopicsArray method returns an array of available topics. This is the same data as getTopicsList() but in an array.

getFortune()

String getFortune(string topics, integer minLength, integer maxLength)

The getFortune() method returns a single random fortune.

Argument Name Type Description
Topics String A comma delimited list of topics to restrict the fortune to. Pass an empty string to use all topics.
minLength Integer The minimum length of the fortune to return. Use 0 to allow any length.
maxLength Integer The maximum length of fortune to return. Use 0 to allow any length. MaxLength must be greater than or equal to minLength.

getFortuneByPattern()

String getFortuneByPattern(string regex, string caseSensitive, string topics, integer minLength, integer maxLength)

The getFortuneByPattern() method returns a single random fortune which matches the provided regular expression.

Argument Name Type Description
Regex String A regular expression to match.
CaseSensitive Boolean Indicates if the regular expression is case sensitive.
Topics String A comma delimited list of topics to restrict the fortune to. Pass an empty string to use all topics.
minLength Integer The minimum length of the fortune to return. Use 0 to allow any length.
maxLength Integer The maximum length of fortune to return. Use 0 to allow any length. MaxLength must be greater than or equal to minLength.

getFortunesByPattern()

Array getFortunesByPattern(regex, caseSensitive, topics, minLength, maxLength)

The getFortunesByPattern() method returns an array of all fortunes which match the provided regular expression.

Argument Name Type Description
Regex String A regular expression to match.
CaseSensitive Boolean Indicates if the regular expression is case sensitive.
Topics String A comma delimited list of topics to restrict the fortune to. Pass an empty string to use all topics.
minLength Integer The minimum length of the fortune to return. Use 0 to allow any length.
maxLength Integer The maximum length of fortune to return. Use 0 to allow any length. MaxLength must be greater than or equal to minLength.