I think, I have the base string now, the signature and all the other
data. I validated it with http://quonos.nl/oauthTester/ and everything
is fine. However, I am still gettin 401 or 501 error.

This is my base string:

POST&http%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses
%2Fupdate.xml&oauth_consumer_key%3D0E1xSiyE03RTEms3WfQ%26oauth_nonce
%3D1000000001%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
%3Doauth_timestamp%26oauth_token%3D88893619-
JS87TMQDkUjM7Ufq119njayEJBuihVQmMEuTu3Ugi%26oauth_version
%3D1.0%26status%3DHallo%252C%2520hier%2520ist%2520Lars

I think I still don't know exactly how to send all the data to twitter
using HTTP::Request (I don't have Net::OAuth). My code:

my $request = HTTP::Request->new(POST => $api_url);
$request->header(
     authorization => 'OAuth realm="https://api.twitter.com/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
     status => $status
      );
$request->content_type("text/xml; charset=utf-8");
my $res = $ua->request($request);

Can someone help me?

On Sep 3, 10:46 am, Tom van der Woerdt <i...@tvdw.eu> wrote:
> I usually use Wireshark for that, but it won't work with https://
> connections. If you use cURL in PHP, there's an option for verbose
> output. I'm not sure about Perl, but Wireshark should help :)
>
> Tom
>
> On 9/3/10 10:42 AM, Lars wrote:
>
> > I Tom,
>
> > thanks for the validator! This is really a helpful tool. Can you
> > explain me how to generat a dump of my http request? I have no idea
> > how to do this in Perl.
>
> > Thanks & Best regards,
> > Lars
>
> > On Sep 3, 9:41 am, Tom van der Woerdt <i...@tvdw.eu> wrote:
> >> On 9/3/10 12:28 AM, Lars wrote:> Why aren't my answers to Tom being 
> >> displayed?
>
> >> No idea.
>
> >>> I based my program on the exmaples I found 
> >>> underhttp://apiwiki.twitter.com/OAuth-Examples
> >>> especially on the example of Scott 
> >>> Carterhttp://www.social.com/main/twitter-oauth-using-perl/.
> >>> I followed his comment:
>
> >>> # Add padding character to make a multiple of 4 per the
> >>>     # requirement of OAuth.
> >>>     $signature .= "=";
>
> >> As long as the amount of characters is a multiple of 4, it's fine. :)
>
> >>>> I also noticed that you don't URL encode the values in $content. If I
> >>>> recall correctly, you have to URL encode those as well.
>
> >>> I think I do encode them with
>
> >>> my $signature_base_str = "POST&" . uri_escape_RFC3986($api_url) .
> >>> "&" . uri_escape_RFC3986($content);
>
> >>> correct?
>
> >> No, you need to urlencode the key/value as well, and later urlencode the
> >> complete body.
>
> >>>> If that was not the issue, then please show your Base String and the
> >>>> HTTP request.
>
> >>> This is the base string:
>
> >>> POST&http%3A%2F2Fapi.twitter.com%2F1%2Fstatuses
> >>> %2Fupdate.json&oauth_consumer_key%3DXXX%26oauth_nonce
> >>> %3D10000000001%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
> >>> %3D1272325550%26oauth_token%3DXXX%26oauth_version%3D1.0%26status
> >>> %3DHello%20world
>
> >> Quoting my validator (http://quonos.nl/oauthTester/) :
> >> # Bad URL encoding!
> >> # Both key and value in the POST body need to be URL encoded.
>
> >>> What do you mean with show us the HTTP request. I think I am doing the
> >>> HTTP request with
>
> >>> my $ua = LWP::UserAgent->new;
> >>> my $req = POST($api_url => [
> >>>            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,
> >>>            status => $status
> >>>            ]);
>
> >>> # Make the request
> >>> my $res = $ua->request($req);
>
> >> Actually I meant a dump of the request you make, like the "POST
> >> /endpoint HTTP/1.1" part, including headers.
>
> >> Tom
>
> >>> On 3 Sep., 00:23, Lars <lars_sa...@hotmail.com> wrote:
> >>>> Sorry, I don't habe shell access...
>
> >>>> On 3 Sep., 00:20, Marc Mims <marc.m...@gmail.com> wrote:
>
> >>>>>> I am not a Perl expert but I have developed a small web page with Perl
> >>>>>> which is somewhat popular in Germany (according to Alexa trafic rank <
> >>>>>> 1000). And this web site is tweeting important events using its own
> >>>>>> twitter account.
>
> >>>>>> I tried for days but I am not able to get it working (tweeting) again.
>
> >>>>>> I registered my web page/application and want to use my access tokens
> >>>>>> "oauth_token" and "oauth_token_secret" which I find under my
> >>>>>> application settings because I am using only this twitter account to
> >>>>>> tweet (seehttp://dev.twitter.com/pages/oauth_single_token)
>
> >>>>>> But the response is always "401 Unauthorized"!
>
> >>>>>> Any ideas?
>
> >>>>>> My Perl program looks like this (my provider does not offer the module
> >>>>>> NET::Twitter)
>
> >>>>> If you have shell access, you can probably install local::lib using the
> >>>>> bootstrap method, then install Net::Twitter or Net::Twitter::Lite in
> >>>>> your own directory.
>
> >>>>>         -Marc

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en

Reply via email to