On Thu, Apr 30, 2009 at 11:22 PM, Jesse Stay <[email protected]> wrote:
> I just wanted to bring back attention to this. Has anyone on the list > gotten Twitter's OAuth to work with Perl? Care to share some code examples? > I'm using Perl's Net::OAuth heavily, but only for updating twitter status with existing access tokens (as my backend processing is Perl, while the frontend is RoR, so authorisation/key exchange is handled through rails OAuth). I did find one bug which I've reported back to the Net::OAuth CPAN maintainer, who said he'll implement in a future release: The issue relates to http://code.google.com/p/twitter-api/issues/detail?id=433#c32 (there's lots of useful into in this thread) The problem occurs when you pass an extra_param containing certain Unicode characters. What happens is that the parameter is passed to the signature creation, and the signature ends up wrong, leading to 401 errors when trying to make a request. The fix for this is actually detailed in the above thread, a problem with the regexp doing the escaping. In Perl's case, the below change to Net::OAuth's Message.pm fixes this: sub encode { my $str = shift; $str = "" unless defined $str; # return URI::Escape::uri_escape_utf8($str,'^\w.~-'); # MM, fix based on twitter OAuth bug report return URI::Escape::uri_escape($str,'^0-9a-zA-Z\d._~-'); } I'm not sure if this is relevant to you given your previous messages, but thought I'd share just in case. With this fix implemented, it seems to work very well, more than 10,000 of my users have migrated to OAuth and I'm doing hundreds of thousands OAuth-based status update requests, without obvious problems. Mario.
