?

Log in

No account? Create an account
XML - LJ.XMLRPC.postevent - props member - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

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

XML - LJ.XMLRPC.postevent - props member [May. 18th, 2004|08:31 pm]
LiveJournal Client Discussions

lj_clients

[krolain]
[mood |confusedconfused]

Evening everyone.

I got another question (I hope I'm not bugging anyone too much) regarding the postevent through XML this time.

So far, it seems whenever I use this member I get an LJ XML parsing issue. So, I'm rather confused on how to use this member to set the various properties. Based on the document, I tried it these way so far:

<MEMBER>
  <NAME>props</NAME>
  <VALUE>
    <ARRAY>
      <DATA>
        <VALUE>
          <STRUCT>
            <MEMBER>
              <NAME>current_mood</NAME>
              <VALUE><STRING>curious</STRING><VALUE>
            </MEMBER>
           </STRUCT>
         </VALUE>
        <VALUE>
          <STRUCT>
            <MEMBER>
              <NAME>current_music</NAME>
              <VALUE><STRING>music</STRING><VALUE>
            </MEMBER>
           </STRUCT>
         </VALUE>
       </DATA>
     </ARRAY>
   </VALUE>
</MEMBER>


and I also tried it in this way:

<MEMBER>
  <NAME>props

So, both these things seems to get me a parsing error from LJ.  Are both these correct, or is there another way?  Is the document up to date on this?  I'm just a bit confused about this and getting a tad furstrated.  I even tried with just one prop and it fails.  I know my XML code work because I can do other things like log in and view, add, remove and edit my LJ groups and LJ friend lists.

Help would be appreciated.

Thanks everyone!
linkReply

Comments:
From: m_leprae
2004-05-18 09:11 pm (UTC)
I found the document to be misleading. It's not really an array.
There's another post buried somewhere that shows how to do it, but to save you the trouble, this is how I did it in my client:
<member>
  <name>props</name>
  <value>
    <struct>
      <member>
        <name>opt_noemail</name>
        <value><boolean>1</boolean></value>
      </member>
      <member>
        <name>opt_nocomments</name>
        <value><boolean>1</boolean></value>
      </member>
      <member>
        <name>current_mood</name>
        <value><string>mood</string></value>
      </member>
      <member>
        <name>current_music</name>
        <value><string>music</string></value>
      </member>
    </struct>
  </value>
</member>
The documentation on goathack is more up to date, but I don't know if they fixed this particular gotcha.
(Reply) (Thread)
[User Picture]From: darklyng
2004-05-20 01:30 am (UTC)
What he said. The props item must contain a single struct, not an array of them. The docs are simply wrong.
(Reply) (Parent) (Thread)
[User Picture]From: krolain
2004-05-22 11:03 am (UTC)
Thanks for the help. It's what I suspected, but I wanted someone else to confirm it.
(Reply) (Parent) (Thread)
[User Picture]From: krolain
2004-05-22 11:02 am (UTC)
Thanks a lot... that fixed the problem. I had a feeling this was the answer, but I wanted to make sure before I spend mroe time on it ;-P

Someone should update the documents.
(Reply) (Parent) (Thread)
From: m_leprae
2004-05-22 01:45 pm (UTC)
There's another gotcha that I ripped my hair over. One of the methods doesn't work unless you supply the version #. The example in the docs omitted it so I did too. I think it was in the challenge/response login.
(Reply) (Parent) (Thread)
[User Picture]From: krolain
2004-05-22 02:39 pm (UTC)
Ah... well I use the version number in all my protocol right now. So I don't have problems with any of them so far.

However, there is something I found that I tried to find answers to but it wasn't done. It appears that music and moods doesn't support non-english characters. If I use the character 'é' for example, I can post it in the subject or entry field, but it won't appear on the music or mood field. It only happens in XML-RPC protocol... not flat. Am I the only one having this issue? o.O

At this rate, I may have to keep support for both flat and XML, flat for multi-lingual. Or is there something undocumented for supporting special characters like that in music/emotion fields?
(Reply) (Parent) (Thread)
From: m_leprae
2004-05-23 12:05 am (UTC)
I had problems with posting certain character values > 127. I believe you need to convert them into %XX, where XX is the hexidemical value of the character. You can do that for the flat protocol as well. The Semagic client seems to do it.

(Reply) (Parent) (Thread)
[User Picture]From: krolain
2004-05-23 02:16 pm (UTC)
Hi.

Thanks for the tip, but I tried it and it didn't work. It just doesn't like using special characters. I dunno why.

So, after many trials and error, I managed to figure it out how to do it. The best way is to encode the text into base64-encoded binary. I stumbled upon this answer when one of my post ended up being sent to me in binary. I knew it was text since it was a post that I used the same special character. Once I decoded the binary into bytes, then UTF-8 decoded that, the text appeared correctly.

So, the way to do it is:
1. UTF-8 byte encode the text
2. Encode the bytes into base64-encoded binary

That seems to work! :-) I may use base64 binary for all my text posting onto LJ.
(Reply) (Parent) (Thread)
[User Picture]From: hythloday
2004-05-18 09:45 pm (UTC)
<MEMBER>
  <NAME>current_mood</NAME>
  <VALUE><STRING>curious</STRING><VALUE>
</MEMBER>
Should be </VALUE>.
(Reply) (Thread)
[User Picture]From: krolain
2004-05-22 11:04 am (UTC)

Thanks. Actually that was jus a manual typo I did. My program sends the proper :-)
(Reply) (Parent) (Thread)