Subject: | [Patch] relationship_exists *still* broken (blame Twitter) |
Arrggg!!!
Twitter is returning the *string* "true" or "false", not the boolean
true or false. JSON::XS throws an exception. JSON::Syck returns the
string "true" or "false". I haven't tested the other providers, but if
they all handle JSON correctly, none of them will return what we want.
I hadn't noticed there were two bug reports for relationship_exists. I
replied to #41667 with a patch that you applied, which would have worked
if Twitter was returning a valid boolean.
The older report, #40835 includes a working patch. However, it will
break if Twitter ever fixes it's API to return a proper boolean.
So, attached is a patch to 1.20 that will work in either case. I'll
also report the bug to Twitter if I don't find an existing bug report,
there.
-Marc
Subject: | net-twitter.patch |
diff --git a/lib/Net/Twitter.pm b/lib/Net/Twitter.pm
index d42fbe4..f32b569 100755
--- a/lib/Net/Twitter.pm
+++ b/lib/Net/Twitter.pm
@@ -418,8 +418,8 @@ sub relationship_exists {
my $req = $self->{ua}->get( $url );
$self->{response_code} = $req->code;
$self->{response_message} = $req->message;
- return ( $req->is_success ) ? JSON::Any->jsonToObj( $req->content ) : undef;
-
+ return unless $req->is_success;
+ return $req->content =~ /true/ ? 1 : 0;
}
########################################################################