I'm using WWW::Mechanize. For the methods that do not require authentication, I get those as I would any other url, and then use the perl JSON module to parse out whatever data I want:
my $response = $mech->get('http://api.stackexchange.com/1.1/questions?fromdate=' . $lasthour)
my $q = from_json($response->content())
I've used Mechanize to log into websites in the past, but the Oauth stuff is confusing, and what documentation is provided for using the API suggests that it is intended for web applications (that require registration with StackExchange?).
In particular, I am interested in the notifications method though I would expect the correct code to allow access to any of the auth-required methods.
Have you looked at Net::StackExchange2?
#for methods that require auth.
my $se = Net::StackExchange2->new(
{
site=>"stackoverflow",
access_token => '<THE ACCESS TOKEN>' ,
key => '<YOUR APP KEY>'
}
);
It uses LWP::UserAgent. Even if you don't want to use the Net::StackExchange2 module directly, you have a good chance of finding some good example code to borrow from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With