Subject: | Message->to_xml doesn't work correctly |
Dear,
I don't know much about Perl.. so I'm not sure whether it is bug or just my misunderstanding.
I wrote following code (I refered from standalone trackback implementation) :
my $msg = $client->send_ping($ping);
my $msg_str = $msg->to_xml;
my ($code, $message) = ($msg_str =~ m!<error>(\d+).*<message>(.*?)</message>!s);
However, I found that the $message is always empty even when $code is 1 or 404, etc. I tried to print $msg->to_xml. The output is always
<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<error>1</error> <-- code is set correctly
<message></message> <-- message is always empty
</response>
I looked into Ping.pm and Message.pm. Then I found such code
(in "parse" function in Ping.pm)
return Net::Trackback::Message->new(
{ code=>1, message=>'No Trackback ID (tb_id)' } )
<-- field name is "message"
(in "to_xml" function in Message.pm)
my $msg = Net::Trackback->encode_xml($self->{__stash}->{msg}) || '';
<-- field name is "msg"
So, I replaced "msg" by "message" in Message.pm. After that, the error message is shown correctly. For example:
<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<error>1</error>
<message>No Trackback ID (tb_id)</message> <-- message is shown
</response>
Of course, I have no idea what side effect my change would result in. (As I have said, I don't know perl..)
I looked into all *.pm files and there are so many "message" and "msg" in code. I can't even guess which of them have to be fixed or not. I wish you fix such problem and my report could be helpful. :-)
I have to thank you for such a good module. I'm adding the trackback functionality in my homepage and the module made it very easier. Thank you very much!
G.Y. Park in South Korea