* sftriman <dal...@gmail.com> [100930 10:01]:
> I have a VPS, so I should be able to update perl modules as I'd like
> to.
> Is there some dependency tree that is causing the HTTP::Message
> (and/or HTTP::Request) module to be held back?  Rather than use
> the local::lib approach, I'd just like to get the latest and greatest
> code
> on my server.  Have you run into my problem before?

The problem seems to be on your server.  Whatever cpan mirror it is
pointed at is out of date.  You may need to contact your hosting
provider for assistance with that.

Yes.  I have received reports of this problem before.  Updating
HTTP::Request has resolved the issue for the other reporters.  I need to
update Net::Twitter's Makefile.PL to reflect the dependency, but I
haven't, yet, determined the oldest version of HTTP::Request that
resolves the problem.

> In case it made any difference, I tried both:
> 
> $twit->update($tweet);
> my $res = $twit->update({ status => $tweet });

Those 2 calls are identical.  Net::Twitter transforms the first into the
same format as the 2nd internally.

> 
> and still got:
> 
> HTTP::Message content not bytes at /usr/lib/perl5/site_perl/5.8.8/HTTP/
> Request/Common.pm line 90
> 
> in both cases.  Would love to get this fixed!  I really appreciate
> that
> you wrote Net::Twitter, it's been awesome.

Here's a workaround that might help.  Caveat: it will only work with
ASCII status content.  If you post any characters with high bits set,
you'll post improperly encoded UTF8.

    {
        package My::NetTwitter;
        use Moose;
        use namespace::autoclean;

        extends 'Net::Twitter::Core';
        with 'Net::Twitter::Role::OAuth',
            'Net::Twitter::Role::API::REST';
            # any other traits you want

        override _encode_args => sub { $_[1] };

        __PACKAGE__->meta->make_immutable;

        1;
    }

    my $twit = My::NetTwitter->new(
        consumer_key => $key,
        #...
    );

    $twit->update($tweet);

It might work, for all text (ASCII/Latin-1 and UTF8) to replace the
"override" line above with this:

        use Encode qw/encode_utf8/;
        around _encode_args => sub {
            my $orig = shift;

            my $args = $orig->(@_);
            return { map { ref ? $_ : encode_utf8 $_ } %$args;
        };

Let me know if that resolves it for you.

        -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

Reply via email to