Thank you for your suggestion.
It is true that referring not only $twit->create_friend() but also $twit->http_code and $twit->http_messages methods is also enough to judge that $twit->create_friend operation is success or failure.
But, don't you think some of the users want to know the reason why 2xx code is not responded(blocked, 2000 over, etc.). For now, users never get an information of http header and body, unless 2xx code is responded. And, in some situations of failure, http body contains more detailed information of failure than http response codes.
For example, it seems to be 5 error cases responding "403 Forbidden".
1. You have been blocked from following this account at the request of the user.
2. You are unable to follow more people. Please read about our following limits
3. You've already requested to follow user.
4. User not found.
5. User is already on your list.
If these errors are responded, users can recognize $twit->create_friend() is faild but never know the reason of failure. Because $twit->create_friend() and $twit never contain information of http body;
I have ran bellow test code, and sniffed packets. For each 5 error cases, request and response http packets are also shown bellow. Dumped $twit->create_friend() is always undef. And unfortunately, $twit have not contain any information the reason of failure.
I think for some users, at least for me, the reason of failure is important information. I would appreciate if you could take my opinion into consideration.
Thank you for reading.
TEST CODE
#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;
use Net::Twitter;
my $twit = Net::Twitter->new(
username => '********',
password => '********',
);
my $args = {
id => '********',
follow => 1,
};
my $res = $twit->create_friend($args);
print &Dumper($res);
print &Dumper($twit);
exit;
1. You have been blocked from following this account at the request of the user.
REQUEST
POST /friendships/create/********.json HTTP/1.1.
TE: deflate,gzip;q=0.3.
Connection: TE, close.
Authorization: Basic ************************.
Host: twitter.com.
User-Agent: Net::Twitter/1.21 (PERL).
Content-Length: 11.
Content-Type: application/x-www-form-urlencoded.
X-Twitter-Client-URL::
http://x4.net/twitter/meta.xml.
X-Twitter-Client-Version:: 1.21.
X-Twitter-Client:: Perl Net::Twitter.
.
follow=true
RESPONSE
HTTP/1.1 403 Forbidden.
Date: Fri, 19 Dec 2008 22:29:34 GMT.
Server: hi.
Last-Modified: Fri, 19 Dec 2008 22:29:34 GMT.
Status: 403 Forbidden.
Pragma: no-cache.
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0.
Content-Type: application/json; charset=utf-8.
Content-Length: 161.
Expires: Tue, 31 Mar 1981 05:00:00 GMT.
Set-Cookie: _twitter_sess=****************************************************************************************************************************************************************************************; domain=.twitter.com; path=/.
Vary: Accept-Encoding.
Connection: close.
.
{"request":"\/friendships\/create\/********.json","error":"Could not follow user: You have been blocked from following this account at the request of the user."}
2. You are unable to follow more people. Please read about our following limits
REQUEST
POST /friendships/create/*******.json HTTP/1.1.
TE: deflate,gzip;q=0.3.
Connection: TE, close.
Authorization: Basic ************************.
Host: twitter.com.
User-Agent: Net::Twitter/1.21 (PERL).
Content-Length: 11.
Content-Type: application/x-www-form-urlencoded.
X-Twitter-Client-URL::
http://x4.net/twitter/meta.xml.
X-Twitter-Client-Version:: 1.21.
X-Twitter-Client:: Perl Net::Twitter.
.
follow=true
RESPONSE
HTTP/1.1 403 Forbidden.
Date: Fri, 19 Dec 2008 22:39:40 GMT.
Server: hi.
Last-Modified: Fri, 19 Dec 2008 22:39:40 GMT.
Status: 403 Forbidden.
Pragma: no-cache.
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0.
Content-Type: application/json; charset=utf-8.
Content-Length: 232.
Expires: Tue, 31 Mar 1981 05:00:00 GMT.
Set-Cookie: _twitter_sess=****************************************************************************************************************************************************************************************; domain=.twitter.com; path=/.
Vary: Accept-Encoding.
Connection: close.
.
{"request":"\/friendships\/create\/*******.json","error":"Could not follow user: You are unable to follow more people. Please read about our <a href=\"http:\/\/help.twitter.com\/index.php?pg=kb.page&id=242\">following limits<\/a>."}
3. You've already requested to follow user.
REQUEST
POST /friendships/create/*******.json HTTP/1.1.
TE: deflate,gzip;q=0.3.
Connection: TE, close.
Authorization: Basic ************************.
Host: twitter.com.
User-Agent: Net::Twitter/1.21 (PERL).
Content-Length: 11.
Content-Type: application/x-www-form-urlencoded.
X-Twitter-Client-URL::
http://x4.net/twitter/meta.xml.
X-Twitter-Client-Version:: 1.21.
X-Twitter-Client:: Perl Net::Twitter.
.
follow=true
RESPONSE
HTTP/1.1 403 Forbidden.
Date: Fri, 19 Dec 2008 22:26:17 GMT.
Server: hi.
Last-Modified: Fri, 19 Dec 2008 22:26:17 GMT.
Status: 403 Forbidden.
Pragma: no-cache.
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0.
Content-Type: application/json; charset=utf-8.
Content-Length: 126.
Expires: Tue, 31 Mar 1981 05:00:00 GMT.
Set-Cookie: _twitter_sess=****************************************************************************************************************************************************************************************; domain=.twitter.com; path=/.
Vary: Accept-Encoding.
Connection: close.
.
{"request":"\/friendships\/create\/*******.json","error":"Could not follow user: You've already requested to follow *******."}
4. User not found.
REQUEST
POST /friendships/create/********.json HTTP/1.1.
TE: deflate,gzip;q=0.3.
Connection: TE, close.
Authorization: Basic ************************.
Host: twitter.com.
User-Agent: Net::Twitter/1.21 (PERL).
Content-Length: 11.
Content-Type: application/x-www-form-urlencoded.
X-Twitter-Client-URL::
http://x4.net/twitter/meta.xml.
X-Twitter-Client-Version:: 1.21.
X-Twitter-Client:: Perl Net::Twitter.
.
follow=true
RESPONSE
HTTP/1.1 403 Forbidden.
Date: Fri, 19 Dec 2008 22:21:20 GMT.
Server: hi.
Last-Modified: Fri, 19 Dec 2008 22:21:20 GMT.
Status: 403 Forbidden.
Pragma: no-cache.
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0.
Content-Type: application/json; charset=utf-8.
Content-Length: 99.
Expires: Tue, 31 Mar 1981 05:00:00 GMT.
Set-Cookie: _twitter_sess=****************************************************************************************************************************************************************************************; domain=.twitter.com; path=/.
Vary: Accept-Encoding.
Connection: close.
.
{"request":"\/friendships\/create\/********.json","error":"Could not follow user: User not found."}
5. User is already on your list.
REQUEST
POST /friendships/create/********.json HTTP/1.1.
TE: deflate,gzip;q=0.3.
Connection: TE, close.
Authorization: Basic ************************.
Host: twitter.com.
User-Agent: Net::Twitter/1.21 (PERL).
Content-Length: 11.
Content-Type: application/x-www-form-urlencoded.
X-Twitter-Client-URL::
http://x4.net/twitter/meta.xml.
X-Twitter-Client-Version:: 1.21.
X-Twitter-Client:: Perl Net::Twitter.
.
follow=true
RESPONSE
HTTP/1.1 403 Forbidden.
Date: Fri, 19 Dec 2008 22:11:39 GMT.
Server: hi.
Last-Modified: Fri, 19 Dec 2008 22:11:39 GMT.
Status: 403 Forbidden.
Pragma: no-cache.
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0.
Content-Type: application/json; charset=utf-8.
Content-Length: 117.
Expires: Tue, 31 Mar 1981 05:00:00 GMT.
Set-Cookie: _twitter_sess=****************************************************************************************************************************************************************************************; domain=.twitter.com; path=/.
Vary: Accept-Encoding.
Connection: close.
.
{"request":"\/friendships\/create\/********.json","error":"Could not follow user: ******** is already on your list."}