?

Log in

No account? Create an account
postevent clarification - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

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

postevent clarification [Jan. 14th, 2004|02:51 pm]
LiveJournal Client Discussions

lj_clients

[vzaliva]
I am little confused by 'postevent' method description in XML-RPC protocol. Particularly I am not sure I am interpreting correctly 'props' element structure.

My interpretation (please correct me if I am wrong) is that 'props' is array of structures. Each structure can have elements, where element name is same as property you want to set and element value is this property value.

What I do not understand, is why there is an array of such structures? What is wrong with putting all properties in one structure?
linkReply

Comments:
From: evan
2004-01-14 04:05 pm (UTC)
that's right, i think. it's mostly a map of the flat protocol.

but i think the point is that some fields can be absent and new fields can be added to the array; leaving out fields of a structure ought to be an error.
(Reply) (Thread)
[User Picture]From: oosabeansaladen
2004-01-26 02:04 pm (UTC)
I'm developing an LJ client in Java with XML-RPC and I'm asking myself the same question.

In Java, struct = Hashtble and array = Vector

So that would mean, if I understand right, that I send a struct which has a key "props" and value a Vector, which itself contains a bunch of Hashtables that contain only one key/value pair (i.e. current_mood, current_mood, etc... )

Either that or the Vector contains only one hashtable which contains all the key/value pairs that "props" has.

Have you figured out which one it is?
(Reply) (Thread)
[User Picture]From: vzaliva
2004-01-26 07:07 pm (UTC)

still need help

not yet. Here is my sample request:

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>LJ.XMLRPC.postevent</methodName>
<params>
 <param>
  <value>
   <struct>
    <member>
     <name>username</name>
     <value>
      <string>some_user</string>
     </value>
    </member>
    <member>
     <name>password</name>
     <value>
      <string>some_pass</string>
     </value>
    </member>
    <member>
     <name>event</name>
     <value>
      <string>123</string>
     </value>
    </member>
    <member>
     <name>lineendings</name>
     <value>
      <string>unix</string>
     </value>
    </member>
    <member>
     <name>subject</name>
     <value>
      <string>1</string>
     </value>
    </member>
    <member>
     <name>usejournal</name>
     <value>
      <string>ansv</string>
     </value>
    </member>
    <member>
     <name>year</name>
     <value>
      <int>2004</int>
     </value>
    </member>
    <member>
     <name>mon</name>
     <value>
      <int>1</int>
     </value>
    </member>
    <member>
     <name>day</name>
     <value>
      <int>26</int>
     </value>
    </member>
    <member>
     <name>hour</name>
     <value>
      <int>18</int>
     </value>
    </member>
    <member>
     <name>min</name>
     <value>
      <int>57</int>
     </value>
    </member>
    <member>
     <name>props</name>
     <value>
      <array>
       <data>
        <value>
         <struct>
          <member>
           <name>current_mood</name>
           <value>
            <string/>
           </value>
          </member>
          <member>
           <name>current_music</name>
           <value>
            <string/>
           </value>
          </member>
          <member>
           <name>opt_preformatted</name>
           <value>
            <boolean>0</boolean>
           </value>
          </member>
          <member>
           <name>opt_nocomments</name>
           <value>
            <boolean>0</boolean>
           </value>
          </member>
          <member>
           <name>opt_backdated</name>
           <value>
            <boolean>0</boolean>
           </value>
          </member>
          <member>
           <name>opt_noemail</name>
           <value>
            <boolean>0</boolean>
           </value>
          </member>
         </struct>
        </value>
       </data>
      </array>
     </value>
    </member>
   </struct>
  </value>
 </param>
</params>
</methodCall>


which cause server error response:

<?xml version="1.0" encoding="UTF-8"?><methodResponse><fault><value><struct><member><name>faultString</name><value><string>No such pseudo-hash field "unknown8bit" at /home/lj/cgi-bin/ljprotocol.pl line 483, <Sock_10.0.0.21:11211> line 3.
</string></value></member><member><name>faultCode</name><value><string>Server</string></value></member></struct></value></fault></methodResponse>







(Reply) (Parent) (Thread)
[User Picture]From: oosabeansaladen
2004-01-30 10:27 am (UTC)
I finally found out how the damn thing works,

You just have to create one struct (an hashtable in Java) with all the keys and their values (opt_nocomments, opt_preformatted, etc). Then you add this struct to the top level struct with the key "props". There is no array in-between.
(Reply) (Thread)
[User Picture]From: vzaliva
2004-01-30 05:09 pm (UTC)

Re:

thanks! I am going to try this.
(Reply) (Parent) (Thread)
[User Picture]From: leprosy
2004-03-27 06:38 pm (UTC)
Thanks! I've been beating my head against that same issue for hours!
(Reply) (Parent) (Thread)
[User Picture]From: the_music_man
2004-04-08 11:22 pm (UTC)
can someone show me an example of the request that is being made? i am using so its not easy to make hashtables or the like, but if you show me an example request i can get it
(Reply) (Parent) (Thread)
[User Picture]From: leprosy
2004-04-09 02:32 pm (UTC)

Here's an example of what I generate.

Replace "the_*" with the appropriate strings and integers.

<?xml version="1.0"?>
<methodCall>
<methodName>LJ.XMLRPC.postevent</methodName>
<params>
<param>
<value><struct>

<member><name>username</name><value><string>the_user</string></value></member>
<member><name>auth_method</name><value><string>challenge</string></value></member>
<member><name>auth_challenge</name><value><string>the_challenge</string></value></member>
<member><name>auth_response</name><value><string>the_response</string></value></member>
<member><name>ver</name><value><int>0</int></value></member>
<member><name>event</name><value><string>the_entry</string></value></member>
<member><name>subject</name><value><string>the_subject</string></value></member>
<member><name>lineendings</name><value><string>unix</string></value></member>
<member><name>security</name><value><string>usemask</string></value></member>
<member><name>allowmask</name><value><int>1</int></value></member>

<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>the_mood</string></value></member>
<member><name>current_music</name><value><string>the_music</string></value></member>

</struct></value>
</member>

<member><name>year</name><value><int>the_year</int></value></member>
<member><name>mon</name><value><int>the_month</int></value></member>
<member><name>day</name><value><int>the_day</int></value></member>
<member><name>hour</name><value><int>the_hour</int></value></member>
<member><name>min</name><value><int>the_min</int></value></member>

</struct></value>
</param>
</params>
</methodCall>
(Reply) (Parent) (Thread)