?

Log in

No account? Create an account
Problems with LJ.XMLRPC.checkfriends - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Problems with LJ.XMLRPC.checkfriends [Sep. 14th, 2005|01:29 pm]
LiveJournal Client Discussions
lj_clients
[wilsonodk]
[mood |awakeawake]
[music |Means To An End - Joy Division]

I'm running into a problem using the CheckFriends method. It keeps returning an error "Application failed during request deserialization: unclosed token at line 1, column 0, byte 0 at /usr/lib/perl5/XML/Parser.pm line 187." Does anyone know what is causing this?

Sent

<?xml version="1.0">
<methodCall>
<methodName>LJ.XMLRPC.checkfriends</methodName>
<params><param><value><struct>
<member><name>username</name><value><string>LJ.psername</string></value></member>
<member><name>password</name><value><string>LJ.password</string></value></member>
<member><name>ver</name><value><int>0</int></value></member>
<member><name>lastupdate</name><value><string></string></value></member>
</struct></value></param></params>
</methodCall>

Returned

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault><value><struct>
<member>
<name>faultString</name>
<value><string>Application failed during request deserialization: 
unclosed token at line 1, column 0, byte 0 at /usr/lib/perl5/XML/Parser.pm line 187
</string></value>
</member>
<member>
<name>faultCode</name>
<value><string>Client</string></value>
</member>
</struct></value></fault>
</methodResponse>

Thanks for your help.

linkReply

Comments:
[User Picture]From: marksmith
2005-09-26 10:45 pm (UTC)
I see that error when the request doesn't get properly sent. For example, when you post without a content-length, or send an empty string, or something... what do your HTTP headers look like? (Because the data itself looks fine...)
(Reply) (Thread)
From: snej
2005-09-27 04:34 am (UTC)
It looks like the error message is telling you exactly what's wrong: Your top-level 'xml' tag is unclosed, because you forgot the "?" before the close-bracket at the end of the first line. Compare your first line with that of the response.
(Reply) (Thread)
From: snej
2005-09-27 04:42 am (UTC)
Also: You must be rolling your own XML to have gotten a syntax error like this. It would save you a lot of trouble in the long run if you'd use an XML-RPC library, since it will take care of all the details like closing tags, escaping special characters, and so forth. (For example: I notice you haven't specified an encoding in your first line. That is likely to cause trouble if you include any non-ascii characters in your text.)

I don't know what language/platform you're using, but there's almost certainly an XML-RPC library available for it. (If not, that's a sign to switch languages!)
(Reply) (Thread)
From: wilsonodk
2005-09-27 12:56 pm (UTC)
Thanks for the help!

Yeah, I was rolling my own. I was just throwing something together with JavaScript — I'll look into finding a XML-RPC library.
(Reply) (Parent) (Thread)
From: snej
2005-09-27 05:04 pm (UTC)
Ah … then be aware that, if you're doing this in client-side JS, many (most?) browsers won't let you contact sites (domains) other than the one the page with the script came from. That's a security measure.

So for instance, if you host the script on a page on www.mydomain.com, the browser won't let it contact www.livejournal.com.

If you've been experimenting with HTML files on your disk, you won't have run into this yet, since browsers typically don't put security restrictions on pages from file: URLs. (And it just occurred to me that this might be for a Dashboard or Konfabulator widget, in which case it's also allowed.)
(Reply) (Parent) (Thread)
From: wilsonodk
2005-09-27 05:09 pm (UTC)
Thanks, I was aware of the security limitation. And, yes, it is in fact for a Dashboard widget. :)
(Reply) (Parent) (Thread)