The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebService::TDWTF - retrieve articles from thedailywtf.com

SYNOPSIS

  use WebService::TDWTF;
  my $random_article = tdwtf_article;
  say $random_article->Title;
  say $random_article->Body;

  my $x = tdwtf_article 8301;
  say $x->Title;  # Your Recommended Virus
  my $y = tdwtf_article 'your-recommended-virus'; # $x and $y are equivalent

  my @recent = tdwtf_list_recent;
  say scalar @recent; # 8
  @recent = tdwtf_list_recent 10;
  say scalar @recent; # 10

  my @dec15 = tdwtf_list_recent 2015, 12;
  say $dec15[0]->Title; # Best of 2015: The A(nti)-Team
  say $dec15[0]->Body;  # (this makes an API call, see NOTES)
  say $dec15[0]->Body;  # (this doesn't make an API call)

  my @erik = tdwtf_list_author 'erik-gern'; # (most recent 8 articles by Erik Gern)
  my @sod  = tdwtf_list_series 'code-sod', 5;  # (most recent 5 CodeSOD articles)

  # All Error'd articles published in January 2014
  my @jan14_errord = tdwtf_list_series 'errord', 2014, 1;

  my @series = series;           # List of all series
  my $series = series;           # Number of series ($series == @series)
  print $series[0]->Slug;        # alexs-soapbox
  print $series[0]->Title;       # Alex's Soapbox
  print $series[0]->Description; # <description of this series>
  print $series[0]->CssClass;    # tales

DESCRIPTION

WebService::TDWTF is an interface to the API of http://thedailywtf.com. Quoting the website's sidebar:

    Founded in 2004 by Alex Papadimoulis, The Daily WTF is your
    how-not-to guide for developing software. We recount tales of
    disastrous development, from project management gone spectacularly
    bad to inexplicable coding choices.

This module exports the following functions:

tdwtf_article()
tdwtf_article($id_or_slug)
article()
article($id_or_slug)

With an argument, returns a WebService::TDWTF object representing the article with the given ID or slug.

With no arguments, returns a WebService::TDWTF object representing a random article.

tdwtf_list_recent()
tdwtf_list_recent($count)
tdwtf_list_recent($year, $month)
list_recent()
list_recent($count)
list_recent($year, $month)

With no arguments, returns the most recent 8 articles.

With one argument, returns the most recent $count articles. $count is at most 100.

With two arguments, returns all articles published in the given month of the given year. $month is an integer between 1 and 12.

tdwtf_list_series($slug)
tdwtf_list_series($slug, $count)
tdwtf_list_series($slug, $year, $month)
list_series($slug)
list_series($slug, $count)
list_series($slug, $year, $month)

With no arguments, returns the most recent 8 articles in the given series.

With one argument, returns the most recent $count articles in the given series. $count is at most 100.

With two arguments, returns all articles in the given series published in the given month of the given year. $month is an integer between 1 and 12.

tdwtf_list_author($slug)
tdwtf_list_author($slug, $count)
tdwtf_list_author($slug, $year, $month)
list_author($slug)
list_author($slug, $count)
list_author($slug, $year, $month)

With no arguments, returns the most recent 8 articles by the given author.

With one argument, returns the most recent $count articles by the given author. $count is at most 100.

With two arguments, returns all articles by the given author published in the given month of the given year. $month is an integer between 1 and 12.

tdwtf_series
series

In list context, returns a list of all existing article series. Each series is an unblessed hashref with the keys Slug, Title, Description and CssClass.

In scalar context, returns the number of existing article series.

NOTES

All functions are exported of the name tdwtf_foo are exported by default. The unprefixed variants can be exported on request.

The tdwtf_list_* functions return a list of incomplete WebService::TDWTF::Article objects. These objects contain all of the fields of a normal object, except for BodyHtml and FooterAdHtml. For these objects, the Body mehod of WebService::TDWTF::Article retrieves the BodyHtml and FooterAdHtml fields from the API and saves them into the object.

All tdwtf_list_* functions return articles in reverse chronological order. That is, the first element of the list is the most recent article.

SEE ALSO

http://thedailywtf.com/

https://github.com/tdwtf/WtfWebApp/blob/master/Docs/API.md

AUTHOR

Marius Gavrilescu, <marius@ieval.ro>

COPYRIGHT AND LICENSE

Copyright (C) 2016 by Marius Gavrilescu

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.20.2 or, at your option, any later version of Perl 5 you may have available.