I just looked up the Perl documentation for HTTP::Request and while I'm
not really a Perl programmer, I *think* that this page can help you turn
on verbose logging for requests :
http://search.cpan.org/~gaas/libwww-perl-5.836/lib/HTTP/Config.pm
Also, I noticed that you typed "authorization" instead of
"Authorization". It could make a difference.
Also, you seem to send a content-type of text/xml. Are you sending XML data?
Another thing I noticed is that you seem to send "status" as a header.
It's a POST value. The same goes for the oauth_* parameters, which are
supposed to be part of the Authorization: header.
Tom
On 9/3/10 2:25 PM, Lars wrote:
> 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
> %3D11%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 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 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
> %3D101%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 wrote:
>> Sorry, I don't habe shell access..