के साथ ओथ को समझना मुझे यमर (https://www.yammer.com/api_doc.html) के लिए सरल एपीआई अनुरोध करने में समस्या है। मुझे https://www.yammer.com/api/v1/groups.xml (समूह: समूहों की एक सूची) प्राप्त करने की आवश्यकता है।पर्ल
मैं नेट :: ओथ :: सरल का उपयोग करने की कोशिश कर रहा हूं।
package Yammer;
use strict;
use base qw(Net::OAuth::Simple);
sub new {
my $class = shift;
my %tokens = @_;
return $class->SUPER::new(tokens => \%tokens,
urls => {
authorization_url => "https://www.yammer.com/oauth/authorize",
request_token_url => "https://www.yammer.com/oauth/request_token",
access_token_url => "https://www.yammer.com/oauth/access_token",
},
protocol_version => '1.0a',
);
}
sub view_restricted_resource {
my $self = shift;
my $url = shift;
return $self->make_restricted_request($url, 'GET');
}
sub update_restricted_resource {
my $self = shift;
my $url = shift;
my %extra_params = @_;
return $self->make_restricted_request($url, 'POST', %extra_params);
}
1;
यहाँ और अपने मुख्य कार्यक्रम है: यहाँ मेरी Yammer.pm है
use Yammer;
# Get the tokens from the command line, a config file or wherever
my %tokens = (
consumer_key => 'Baj7MciMhmnDTwj6kaOV5g',
consumer_secret => 'ejFlGBPtXwGJrxrEnwGvdRyokov1ncN1XxjmIm34M',
callback => 'https://www.yammer.com/oauth/authorize',
);
my $app = Yammer->new(%tokens);
# Check to see we have a consumer key and secret
unless ($app->consumer_key && $app->consumer_secret) {
die "You must go get a consumer key and secret from App\n";
}
# If the app is authorized (i.e has an access token and secret)
# Then look at a restricted resourse
if ($app->authorized) {
my $response = $app->view_restricted_resource;
print $response->content."\n";
exit;
}
# Otherwise the user needs to go get an access token and secret
print "Go to " . $app->get_authorization_url(callback => 'https://www.yammer.com/oauth/authorize?rand=' . rand()) . "\n";
print "Then hit return after\n";
<STDIN>;
my ($access_token, $access_token_secret) = $app->request_access_token($_);
मैं की तरह
जाओ संदेश मिल रहा है https://www.yammer.com/oauth/authorize?oauth_token=2sxBkKW1F1iebF2TT5Y7g&callback=https%3A%2F%2Fwww.yammer.com%2Foauth%2Fauthorize%3Frand%3D0.0045166015625
को और इस यूआरएल पर आवेदन अधिकृत।
आप सफलतापूर्वक निम्नलिखित आवेदन अधिकृत किया है:: 2GIS_yammer
प्राधिकरण को पूरा करने के 2GIS_yammer आवेदन करने के लिए वापस जाने के लिए और निम्न कोड दर्ज करें: उसके बाद मैं संदेश की तरह देख
869A
लेकिन अगला क्या है? मुझे इस नंबर को दर्ज करना होगा? मुझे अनुरोध करने का अनुरोध कैसे करें?
धन्यवाद। रोमन
आप हमें बताएँ कि 'Net :: OAuth :: Simple' के लिए यह करने के लिए कर सकते हैं? मैंने इसे '$ ऐप-> सत्यापनकर्ता ('869 ए') के साथ सेट करने का प्रयास किया, लेकिन यह गलत लगता है। और '$ ऐप-> request_access_token ((oauth_verifier => $ पिन)); 'या तो काम नहीं करता है। – cringe