App-RoboBot
view release on metacpan or search on metacpan
lib/App/RoboBot/Plugin/API/Translate.pm view on Meta::CPAN
my ($self) = @_;
# last_authed only changes when it was successful, so if we have a current
# one, skip all the work ahead
return 1 if $self->last_authed > time() - 590;
my $client = $self->bot->config->plugins->{'translate'}{'client'};
my $secret = $self->bot->config->plugins->{'translate'}{'secret'};
my $response = $self->ua->post('https://datamarket.accesscontrol.windows.net/v2/OAuth2-13',
{ grant_type => 'client_credentials',
client_id => $client,
client_secret => $secret,
scope => 'http://api.microsofttranslator.com' });
return 0 unless $response->is_success;
my $json;
eval {
$json = decode_json($response->decoded_content);
};
( run in 0.243 second using v1.01-cache-2.11-cpan-4d50c553e7e )