XML-RPC Protocol Method: getevents

From Dreamwidth Notes
Jump to: navigation, search
Needs Update: This documentation was ported over from LJ's Server Manual with minimal modification. It may not match Dreamwidth's implementation of the method, and needs to be double checked against the DW code and updated as necessary.

Given a set of specifications, will return a segment of entries up to a limit set by the server. Has a set of options for less, extra, or special data to be returned.

Inputs

username Scalar. Required. Username of user logging in.

auth_method Scalar. Optional. Authentication method used for this request. The default value is "clear", for plain-text authentication. "cookie" and any of the challenge-response methods are also acceptable.

password Deprecated. Scalar. Optional. Password of user logging in in plaintext. If using the "clear" authentication method, either this or "hpassword" must be present.

hpassword Deprecated. Scalar. Optional. MD5 digest of user's password. Not much more secure than password, but at least it's not in plain text.

auth_challenge Scalar. Optional. If using challenge-response authentication, this should be the challenge that was issued to you by the server.

auth_response Scalar. Optional. If using challenge-response authentication, this should be the response hash that you generate, based on the formula required for your challenge.

ver Scalar. Optional. Protocol version supported by the client; assumed to be 0 if not specified. See Protocol Versions for details on the protocol version.

truncate Scalar. Required. A value that if greater than or equal to 4, truncates the length of the returned events (after being decoded) to the value specified. Entries less than or equal to this length are left untouched. Values greater than this length are truncated to the specified length minus 3, and then have "... " appended to them, bringing the total length back up to what you specified. This is good for populating list boxes where only the beginning of the entry is important, and you'll double-click it to bring up the full entry.

prefersubject Scalar. Required. If this setting is set to true (1), then no subjects are returned, and the events are actually subjects if they exist, or if not, then they're the real events. This is useful when clients display history and need to give the user something to double-click. The subject is shorter and often more informative, so it'd be best to download only this.

noprops Scalar. Optional. If this setting is set to true (1), then no meta-data properties are returned.

selecttype Scalar. Required. Determines how you want to specify what part of the journal to download. Valid values are day to download one entire day, lastn to get the most recent n entries (where n is specified in the howmany field), one to download just one specific entry, or syncitems to get some number of items (which the server decides) that have changed since a given time (specified in the lastsync parameter). Note that because the server decides what items to send, you may or may not be getting everything that's changed. You should use the syncitems selecttype in conjunction with the syncitems protocol mode.

lastsync Scalar. Optional. For a selecttype of syncitems, the date (in "yyyy-mm-dd hh:mm:ss" format) that you want to get updates since.

year Scalar. Optional. For a selecttype of day, the 4-digit year of events you want to retrieve.

month Scalar. Optional. For a selecttype of day, the 1- or 2-digit month of events you want to retrieve.

day Scalar. Optional. For a selecttype of day, the 1- or 2-digit day of the month of events you want to retrieve.

howmany Scalar. Optional. For a selecttype of lastn, how many entries to get. Defaults to 20. Maximum is 50.

beforedate Scalar. Optional. For a selecttype of lastn, you can optionally include this variable and restrict all entries returned to be before the date you specify, which must be of the form yyyy-mm-dd hh:mm:ss.

itemid Scalar. Optional. For a selecttype of one, the journal entry's unique ItemID for which you want to retrieve. Or, to retrieve the most recent entry, use the value -1. Using -1 has the added effect that the data is retrieved from the master database instead of a replicated slave. Clients with an "Edit last entry" feature might want to send -1, to make sure the data that comes back up is accurate, in case a slave database is a few seconds behind in replication.

lineendings Scalar. Optional. Specifies the type of line-endings you're using. Possible values are unix (0x0A (\n)), pc (0x0D0A (\r\n)), or mac (0x0D (\r) ). The default is not-Mac. Internally, Dreamwidth stores all text as Unix-formatted text, and it does the conversion by removing all \r characters. If you're sending a multi-line event on Mac, you have to be sure and send a lineendings value of mac or your line endings will be removed. PC and Unix clients can ignore this setting, or you can send it. It may be used for something more in the future.

usejournal Scalar. Optional. If getting the history of a shared journal, include this key and the username you wish to get the history of. By default, you load the history of "user" as specified above.

Example Request

POST /interface/xmlrpc HTTP/1.0
User-Agent: XMLRPC Client 1.0
Host: www.dreamwidth.org
Content-Type: text/xml
Content-Length: 786
 
<?xml version="1.0"?>
<methodCall>
  <methodName>LJ.XMLRPC.getevents</methodName>
  <params>
    <param>
      <value><struct>
        <member>
          <name>username</name>
          <value><string>test</string></value>
        </member>
        <member>
          <name>password</name>
          <value><string>test</string></value>
        </member>
        <member>
          <name>ver</name>
          <value><int>1</int></value>
        </member>
        <member>
          <name>truncate</name>
          <value><int>20</int></value>
        </member>
        <member>
          <name>selecttype</name>
          <value><string>lastn</string></value>
        </member>
        <member>
          <name>howmany</name>
          <value><int>2</int></value>
        </member>
        <member>
          <name>noprops</name>
          <value><boolean>1</boolean></value>
        </member>
        <member>
          <name>lineendings</name>
          <value><string>unix</string></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodCall>

Outputs

events Array of structs. Required. A list of structs for all of the returned events. Containing keys:

  • itemid Scalar. Required. The unique integer ItemID of the item being returned.
  • eventtime Scalar. Required. The time the user posted (or said they posted, rather, since users can back-date posts) the item being returned.
  • logtime Scalar. Required. The UTC time that the server logged when the post was first created.
  • security Scalar. Required. If this variable is not returned, then the security of the post is public, otherwise this value will be private or usemask.
  • allowmask Scalar. Optional. If security is usemask then this is defined with the 32-bit unsigned int bit-mask of who is allowed to access this post.
  • subject Scalar. Optional. The subject of the journal entry. This won't be returned if "prefersubjects" is set, instead the subjects will show up as the events.
  • event Scalar. Required. The event text itself. This value is first truncated if the truncate variable is set, and then it is URL-encoded (alphanumerics stay the same, weird symbols to %hh, and spaces to + signs, just like URLs or post request). This allows posts with line breaks to come back on one line.
  • anum Scalar. Required. The authentication number generated for this entry. It can be used by the client to generate URLs, but that is not recommended. (See the returned 'url' element if you want to link to a post.)
  • url Scalar. Required. The permanent link address to this post. This is an opaque string--you should store it as is. While it will generally follow a predictable pattern, there is no guarantee of any particular format for these, and it may change in the future.
  • poster Scalar. Optional. If the poster of this event is different from the user value sent above, then this key will be included and will specify the username of the poster of this event. If this key is not present, then it is safe to assume that the poster of this event is none other than user.
  • props Struct. Optional. Properties and their values for the item being returned. See Journal Entries Metadata for the documentation of the keys and value data types.

Example Response

HTTP/1.1 200 OK
Connection: close
Content-length: 1002
Content-Type: text/xml
Date: Tue, 16 Jul 2002 00:30:01 GMT
Server: Apache/1.3.4 (Unix)
 
<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value><struct>
        <member>
          <name>events</name>
          <value><array><data>
            <value><struct>
              <member>
                <name>eventtime</name>
                <value><string>2020-02-20 02:20:00</string></value>
              </member>
              <member>
                <name>logtime</name>
                <value><string>2020-02-20 08:23:48</string></value>
              </member>
              <member>
                <name>event</name>
                <value><string>yes its true its ...</string></value>
              </member>
              <member>
                <name>anum</name>
                <value><int>108</int></value>
              </member>
              <member>
                <name>itemid</name>
                <value><int>1965</int></value>
              </member>
            </struct></value>
            <value><struct>
              <member>
                <name>eventtime</name>
                <value><string>2002-07-14 11:17:00</string></value>
              </member>
              <member>
                <name>logtime</name>
                <value><string>2002-07-14 17:17:51</string></value>
              </member>
              <member>
                <name>event</name>
                <value><string>Yes, Yes, YES!</string></value>
              </member>
              <member>
                <name>anum</name>
                <value><int>66</int></value>
              </member>
              <member>
                <name>subject</name>
                <value><string>Is this private?</string></value>
              </member>
              <member>
                <name>itemid</name>
                <value><int>1964</int></value>
              </member>
            </struct></value>
          </data></array></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodResponse>