How to access authenticated StackExchange API methods from perl script?

I am using WWW :: Mechanize. For methods that do not require authentication, I get them, like any other URL, and then use the perl JSON module to parse any data I want:

my $response = $mech->get('http://api.stackexchange.com/1.1/questions?fromdate=' . $lasthour)
my $q = from_json($response->content())

I used Mechanize to log in to sites in the past, but the Oauth stuff is confusing, and the documentation provided for using the API suggests that this is for web applications (requires registration with StackExchange?).

In particular, I am interested in the notification method, although I would expect the correct code to allow access to any of the methods required by auth.

+5
source share
1 answer

Net:: StackExchange2?

#for methods that require auth.
my $se = Net::StackExchange2->new(
    {
        site=>"stackoverflow",
        access_token => '<THE ACCESS TOKEN>' ,
        key => '<YOUR APP KEY>'
    }
);

LWP:: UserAgent. Net:: StackExchange2, .

+2

All Articles