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

NAME

WebService::Hatena::Graph - A Perl interface to Hatena::Graph API

SYNOPSIS

  use WebService::Hatena::Graph;

  my $graph = WebService::Hatena::Graph->new(
      consumer_key => $consumer_key,
      consumer_secret => $consumer_secret,
      access_token => $token,
      access_token_secret => $token_secret,

      username => $username,
      password => $api_password,
  );

  # set data to the specified graph
  $graph->post_data(
      graphname => $graphname,
      date      => $date,
      value     => $value,
  );

  # retrieve graph data
  my $graph_data = $graph->get_data(
      graphname  => $graphname,
      username   => $username,
  );

  # set config
  $graph->post_config(
      graphname      => $graphname,
      graphcolor     => $graphcolor,
      graphtype      => $graphtype,
      status         => $status,
      allowuser      => $allowuser,
      allowgrouplist => $allowgrouplist,
      stack          => $stack,
      reverse        => $reverse,
      formula        => $formula,
      maxy           => $maxy,
      miny           => $miny,
      showdata       => $showdata,
      nolabel        => $nolabel,
      userline       => $userline,
      userlinecolor  => $userlinecolor,
      comment        => $comment,
  );

  # retrieve config
  my $graph_config = $graph->get_config( graphname => $graphname );

DESCRIPTION

Hatena::Graph is a website which allows users to manage and share daily activities with graphic representaion. WebService::Hatena::Graph provides an easy way to communicate with it using its API.

METHODS

new ( %args )

      # OAuth
      my $graph = WebService::Hatena::Graph->new(
          consumer_key => $consumer_key,
          consumer_secret => $consumer_secret,
          access_token => $token,
          access_token_secret => $token_secret,
      );
    
      # WSSE
      my $graph = WebService::Hatena::Graph->new(
          username => $username,
          password => $api_password,
      );

    This method creates and returns a new WebService::Hatena::Graph object.

    As arguments to the method, tokens for the OAuth 1.0a application (consumer_key and consumer_secret) and tokens for the user (access_token and access_token_secret) must be specified.

    Alternatively, WSSE authorization scheme is also supported. For WSSE, both username and API password are required. If not passed in, it will croak immediately. New applications should not use WSSE.

post_data ( %args )

      $graph->post_data(
          graphname => $graphname,
          date      => $date,
          value     => $value,
      );

    This method sets $value on $date to the graph specified by $graphname parameter.

    NOTE: If the graphname parameter isn't passed in or the request ends in failure for some reason, this method will croak immediately. Additionally, you might want to consult the official documentation of Hatena::Graph API to know more about how you can pass the parameters in.

    This note is applicable to also all the methods described below except ua() method.

post ( %args )

    This method is an alias of post_data() method described above, but it's already obsolete and remains only for backward compatibility (less or eaqual version 0.04). Use post_data() instead.

get_data ( %args )

      my $graph_data = $graph->get_data(
          graphname  => $graphname,
          username   => $username,
      );

    This method retrieves the data of the graph specified by $graphname and returns a hashref to them.

post_config ( %args )

      $graph->post_config(
          graphname      => $graphname,
          graphcolor     => $graphcolor,
          graphtype      => $graphtype,
          status         => $status,
          allowuser      => $allowuser,
          allowgrouplist => $allowgrouplist,
          stack          => $stack,
          reverse        => $reverse,
          formula        => $formula,
          maxy           => $maxy,
          miny           => $miny,
          showdata       => $showdata,
          nolabel        => $nolabel,
          userline       => $userline,
          userlinecolor  => $userlinecolor,
          comment        => $comment,
      );

    This method sets or updates the configuraions of the graph specified by $graphname.

get_config ( %args )

      my $graph_config = $graph->get_config( graphname => $graphname );

    This method retrieves the configuraions from the graph specified by $graphname and returns a hashref to them.

ua ()

      $graph->ua->timeout(10);

    This method returns LWP::UserAgent object internally used in the WebService::Hatena::Graph object. You can set some other options which are specific to LWP::UserAgent via this method.

SEE ALSO

AUTHOR

Kentaro Kuribayashi <kentaro@cpan.org>

COPYRIGHT AND LICENSE (The MIT License)

Copyright (c) 2006 - 2007, Kentaro Kuribayashi <kentaro@cpan.org>

Copyright 2013 Hatena <http://www.hatena.ne.jp/company/>.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.