Net::OAuth::Yahoo

Provides simple interface to access Yahoo! APIs
Download

Net::OAuth::Yahoo Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Satoshi Yagi
  • Publisher web site:
  • http://search.cpan.org/~syagi/

Net::OAuth::Yahoo Tags


Net::OAuth::Yahoo Description

Net::OAuth::Yahoo is a Perl module that provides a simple interface to access Yahoo! APIs.SYNOPSIS use Net::OAuth::Yahoo; # Construct hashref of OAuth information my $args = { "consumer_key" => "dj0yJmk9TUhIbnlZa0tYVDAzJmQ9WVdrOWMyMUxNVXBoTjJNbWNHbzlNVGd3TnpjMU5qazJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD1lNg--", "consumer_secret" => "93dfc3e0bbeec0c63b86b6f9f3c55772e4f1fe26", "signature_method" => "HMAC-SHA1", "nonce" => "random_string", "callback" => "oob", }; my $oauth = Net::OAuth::Yahoo->new( $args ); # First, obtain the request token my $request_token = $oauth->get_request_token(); # Second, fetch the OAuth URL to be presented to the user my $url = $oauth->request_auth( $request_token ); # Third, obtain the OAuth Verifier. The real way is to present the $url to the end user, have them click on the "Agree" button, then obtain the OAuth Verifier. # I wrote a simulator subroutine that does this, provided Yahoo ID and password. If you go with the real way, you can skip this step. my $yid = { "login" => login, "passwd" => passwd, }; my $oauth_verifier = $oauth->sim_present_auth( $url, $yid ); # Using the OAuth Verifier, let's get the token. my $token = $oauth->get_token( $oauth_verifier ); # Now it's all done, time to access some API! my $api_url = "http://fantasysports.yahooapis.com/fantasy/v2/team/265.l.5098.t.2/players?format=json"; my $json = $oauth->access_api( $token, $api_url ); OTHER METHODS: The token expires after 1 hour, so you can reuse it until then. 3 methods are provided to facilitate the reuse. # Save the token in a YAML file. $oauth->save_token( "filename" ); # Load the token from a YAML file. my $token = $oauth->load_token( "filename" ); # Test the token against an URL. Returns 1 if good, 0 otherwise. my $ret = $oauth->test_token( $token, $url ); TESTS: Due to the nature of this module, information such as consumer_key, consumer_secret is required. I have provided test_deeply.pl in case the user wants to test the module deeply. This test script prompts for various Net::OAuth information as well as Yahoo login / password. DEBUGGING: This module returns "undef" if something goes wrong. Also, an error message is set in $Net::Oauth::Yahoo::ERRMSG. The user can inspect like so: my $request_token = $oauth->get_request_token(); print $Net::OAuth::Yahoo::ERRMSG if ( !defined $request_token );Product's homepage


Net::OAuth::Yahoo Related Software