Thread Twittern mit Perl und Oauth (10 answers)
Opened by Lars at 2010-09-02 23:50

Gast Lars
 2010-09-03 21:44
#141162 #141162
Danke! Ich glaube, das hat mich schon ein gutes Stück weiter gebracht. Ich habe nochmal nachgelesen in der Oautt-Spec (http://oauth.net/core/1.0/#auth_header) und denke, dass der Status nur in den Body muss.

Ich habe das Coding daher noch angepasst:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
my %oauth=(
  oauth_nonce            => $oauth_nonce,
  oauth_signature_method => $oauth_signature_method,
  oauth_timestamp        => $oauth_timestamp,
  oauth_consumer_key     => $oauth_consumer_key,
  oauth_token            => $oauth_token,
  oauth_signature        => $signature,
  oauth_version          => $oauth_version,
);
my $oauth_str=join(", ", map{$_=qq($_="$oauth{$_}")} sort keys(%oauth));

my $request = HTTP::Request->new(POST => $api_url);
$request->header(
     Authorization => 'OAuth realm="https://api.twitter.com/oauth/ ,'.$oauth_str);

$request->content_type("application/x-www-form-urlencoded");
$request->content(status => $status);
my $res = $ua->request($request);


Leider bekomme ich jetzt einen 500er Fehler von Twitter. Wenn ich den Request dumpe erhalten ich folgendes

Code: (dl )
1
2
3
4
5
6
7
8
9
10
$VAR1 = bless( {
'_content' => 'status',
'_uri' => bless( do{\(my $o = 'http://api.twitter.com/1/statuses/update.json')}, 'URI::http' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/5.814',
'content-type' => 'application/x-www-form-urlencoded',
'authorization' => 'OAuth realm="https://api.twitter.com/oauth/ ,oauth_consumer_key="0E1xSiyE03RTEms3WfQ", oauth_nonce="10000000022", oauth_signature="VD0q9A8qqk9l4QlDu8GrUbCTdAg=", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1272325550", oauth_token="88893619-JS87TMQDkUjM7Ufq119njayEJBuihVQmMEuTu3Ugi", oauth_version="1.0"'
}, 'HTTP::Headers' ),
'_method' => 'POST'
}, 'HTTP::Request' );


Irgendeine Idee?
Last edited: 2010-09-03 23:50:00 +0200 (CEST)

View full thread Twittern mit Perl und Oauth