Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-Twitter CPAN distribution.

Report information
The Basics
Id: 35395
Status: resolved
Worked: 20 min
Priority: 0/
Queue: Net-Twitter

People
Owner: cthom [...] cpan.org
Requestors: earle [...] downlode.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: Not working with latest JSON::Any?
The following code: # -------------------------- #!/usr/bin/perl use warnings; use strict; use Net::Twitter; sub twitter { my ($self, $text) = @_; my $twitter = Net::Twitter->new( username => 'whatever', password => 'whatever', ); return $twitter->update($text); } twitter("Test."); # -------------------------- fails with this message: malformed JSON string, neither array, object, number, string or atom, at character offset 1 ["(end of string)"] at /usr/local/share/perl/5.8.8/JSON/Any.pm line 439. JSON::Any is at version 1.16; perl is 5.8.8.
As JSON::Any is just a wrapper, I need to know which JSON modules are "under the hood", and their versions. If you could reply with the results of these five commands, it would help. (This supposes a Unix style command line. I have no idea how to get the info from a windows perl) perl -MJSON -e 'print "$JSON::VERSION\n"' perl -MJSON::XS -e 'print "$JSON::XS::VERSION\n"' perl -MJSON::PC -e 'print "$JSON::PC::VERSION\n"' perl -MJSON::Syck -e 'print "$JSON::Syck::VERSION\n"' perl -MJSON::DWIW -e 'print "$JSON::DWIW::VERSION\n"'
On Fri Apr 25 13:08:12 2008, CTHOM wrote: Show quoted text
> As JSON::Any is just a wrapper, I need to know which JSON modules are > "under the hood", and their versions.
Of course it is. I should have thought of that earlier, sorry. Here you go: earle@oort:~$ perl -MJSON -e 'print "$JSON::VERSION\n"' 2.09 earle@oort:~$ perl -MJSON::XS -e 'print "$JSON::XS::VERSION\n"' 2.01 earle@oort:~$ perl -MJSON::PC -e 'print "$JSON::PC::VERSION\n"' 0.01 earle@oort:~$ perl -MJSON::Syck -e 'print "$JSON::Syck::VERSION\n"' 0.26 earle@oort:~$ perl -MJSON::DWIW -e 'print "$JSON::DWIW::VERSION\n"' 0.19
From: Earle Martin
I've now upgraded all the modules to their latest versions but I'm still getting the same error. earle@oort:~$ perl -MJSON -e 'print "$JSON::VERSION\n"' 2.09 earle@oort:~$ perl -MJSON::XS -e 'print "$JSON::XS::VERSION\n"' 2.2 earle@oort:~$ perl -MJSON::PC -e 'print "$JSON::PC::VERSION\n"' 0.03 earle@oort:~$ perl -MJSON::Syck -e 'print "$JSON::Syck::VERSION\n"' 0.29 earle@oort:~$ perl -MJSON::DWIW -e 'print "$JSON::DWIW::VERSION\n"' 0.24
I have replicated your error. It is not an error in either Net::Twitter, nor JSON::Any. From your test code. sub twitter { my ($self, $text) = @_; ... You are grabbing $self and $text from the arguments passed to the twitter subroutine, except this subroutine is not an object, and so doesn't get passed a $self. This means that your later call to twitter('Test.') is leaving $text blank, and in turn calling the twitter update method with a blank status. I'll put in a bit of code in the next version to check for this and return a reasonable error message. If you change the line above to: sub twitter { my ($text) = @_; your code will work fine.
From: Earle Martin
Wow, that's embarrassing. I copied that code out of something else I'd written - and obviously completely forgot that the old code was OO, while the new code is not. And of course it made me codeblind to the programming error, because as far as I knew it was working code. Sorry to have wasted your time - thanks for looking into it!
Left this one open by mistake.