File Coverage

blib/lib/Net/OpenMicroBlogging.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Net::OpenMicroBlogging;
2 1     1   20865 use warnings;
  1         2  
  1         33  
3 1     1   6 use strict;
  1         2  
  1         43  
4 1     1   6 use base 'Net::OAuth';
  1         6  
  1         910  
5              
6             our $VERSION = '0.01';
7              
8             =head1 NAME
9              
10             Net::OpenMicroBlogging - OpenMicroBlogging protocol support
11              
12             =head1 SYNOPSIS
13              
14             # Consumer sends Request Token Request
15              
16             use Net::OpenMicroBlogging;
17             use HTTP::Request::Common;
18             my $ua = LWP::UserAgent->new;
19              
20             my $request = Net::OpenMicroBlogging->request("request token")->new(
21             consumer_key => 'dpf43f3p2l4k3l03',
22             consumer_secret => 'kd94hf93k423kf44',
23             request_url => 'https://ublog.example.net/request_token',
24             request_method => 'POST',
25             signature_method => 'HMAC-SHA1',
26             timestamp => '1191242090',
27             nonce => 'hsu94j3884jdopsl',
28             omb_listener => 'http://ublog.example.net/bob',
29             );
30              
31             $request->sign;
32              
33             my $res = $ua->request(POST $request->to_url); # Post message to the Service Provider
34            
35             if ($res->is_success) {
36             my $response = Net::OpenMicroBlogging->response('request token')->from_post_body($res->content);
37             print "Got Request Token ", $response->token, "\n";
38             print "Got Request Token Secret ", $response->token_secret, "\n";
39             }
40             else {
41             die "Something went wrong";
42             }
43            
44             # Etc..
45              
46             # Service Provider receives Request Token Request
47            
48             use Net::OpenMicroBlogging;
49             use CGI;
50             my $q = new CGI;
51            
52             my $request = Net::OpenMicroBlogging->request("request token")->from_hash($q->Vars,
53             request_url => 'https://photos.example.net/request_token',
54             request_method => $q->request_method,
55             consumer_secret => 'kd94hf93k423kf44',
56             );
57              
58             if (!$request->verify) {
59             die "Signature verification failed";
60             }
61             else {
62             # Service Provider sends Request Token Response
63              
64             my $response = Net::OpenMicroBlogging->response("request token")->new(
65             token => 'abcdef',
66             token_secret => '0123456',
67             );
68              
69             print $response->to_post_body;
70             }
71              
72             # Etc..
73              
74              
75             =head1 ABSTRACT
76              
77             The purpose of OpenMicroBlogging is
78              
79             "To allow users of one microblogging service to publish notices to users of another service, given the other users' permission."
80              
81             Please refer to the OpenMicroBlogging spec: L
82              
83             OpenMicroBlogging is based on OAuth - familiarity with OAuth is highly recommended before diving into OpenMicroBlogging
84              
85             Net::OpenMicroBlogging is a thin wrapper around L - basically it augments Net::OAuth
86             message classes with additional OMB parameters, and defines a couple message types unique to
87             OMB. Please refer to the L documentation for the details of how to create, manipulate,
88             sign and verify messages.
89              
90             =back
91              
92             =head1 DESCRIPTION
93              
94             =head2 OMB MESSAGES
95              
96             An OpenMicroBlogging message is a set of key-value pairs. The following message types are supported:
97              
98             Requests
99              
100             =over
101              
102             =item * Request Token (Net::OpenMicroBlogging::RequestTokenRequest)
103              
104             =item * Access Token (Net::OpenMicroBlogging::AccessTokenRequest)
105              
106             =item * User Authentication (Net::OpenMicroBlogging::UserAuthRequest)
107              
108             =item * Protected Resource (Net::OpenMicroBlogging::ProtectedResourceRequest)
109              
110             =item * Posting a Notice (Net::OpenMicroBlogging::PostNoticeRequest)
111              
112             =item * Updating a Profile (Net::OpenMicroBlogging::UpdateProfileRequest)
113              
114             =back
115              
116             Responses
117              
118             =over
119              
120             =item * Request Token (Net::OpenMicroBlogging::RequestTokenResponse)
121              
122             =item * Access Token (Net::OpenMicroBlogging:AccessTokenResponse)
123              
124             =item * User Authentication (Net::OpenMicroBlogging::UserAuthResponse)
125              
126             =back
127              
128             =head1 SEE ALSO
129              
130             L
131              
132             =head1 AUTHOR
133              
134             Keith Grennan, C<< >>
135              
136             =head1 COPYRIGHT & LICENSE
137              
138             Copyright 2007 Keith Grennan, all rights reserved.
139              
140             This program is free software; you can redistribute it and/or modify it
141             under the same terms as Perl itself.
142              
143             =cut
144              
145             1;