(archive 'newLISPer)

December 11, 2005

Posting from newLISP

Filed under: newLISP — newlisper @ 21:49
Tags:

Not relevant in the archive version

I’m using the post-url function in newLISP to post to this blog. Here’s the function:

(define (make-new-post blog-id blog-username
     blog-password post-title post-body)
    (write-buffer buffer  (string  (xml-parse
    (post-url  "http://plant.blogger.com/api/RPC2"
    (format "
<?xml version=\"1.0\"?>
<methodCall>
    <methodName>
        blogger2.newPost
    </methodName>
    <params>
        <param>
        <value>
            <struct>
                <member>
                    <name>
                        username
                    </name>
                    <value>
                        <string>
                            %s
                        </string>
                    </value>
                </member>
                <member>
                    <name>
                        password
                    </name>
                    <value>
                        <string>
                            %s
                        </string>
                    </value>
                </member>
                <member>
                    <name>
                        appkey
                    </name>
                    <value>
                        <string>
                            1
                        </string>
                    </value>
                </member>
            </struct>
        </value>
        </param>
        <param>
        <value>
            <struct>
                <member>
                    <name>
                        blogID
                    </name>
                    <value>
                        <string>
                            %s
                        </string>
                    </value>
                </member>
                <member>
                    <name>
                        body
                    </name>
                    <value>
                        <string>
                            %s
                        </string>
                    </value>
                </member>
                <member>
                    <name>
                        title
                    </name>
                    <value>
                        <string>
                            %s
                        </string>
                    </value>
                </member>
                <member>
                    <name>
                        postOptions
                    </name>
                    <value>
                        <struct>
                            <member>
                                <name>
                                    title
                                </name>
                                <value>
                                    <string>
                                        %s
                                    </string>
                                </value>
                            </member>
                        </struct>
                    </value>
                </member>
            </struct>
        </value>
        </param>
        <param>
        <value>
            <struct>
                <member>
                    <name>
                        doPublish
                    </name>
                    <value>
                        <boolean>
                            1
                        </boolean>
                    </value>
                </member>
            </struct>
        </value>
        </param>
    </params>
</methodCall>
" blog-username blog-password blog-id
  post-body post-title post-title) "" 10000 ) (+ 1 2 8)))))

and I call it like this:

(make-new-post blog-id blog-username
              blog-password post-title post-body )

Nearly all of this is the XML request code. The xml-parse function reads the answer from Blogger and formats it for my benefit. If you use this code, reformat the XML to remove stray returns and tabs!

Advertisements

2 Comments »

  1. >I would delimit the long XML string in the (format …) statement with [text]…[/text] tags. I think the XML coming close to 2048 characters the maximum for “…” quoted strings. If you do that, you also can omit the escape back-slash characters before quotes inside the string delimited with [text]…[/text] tags.

    Comment by don Lucio — December 22, 2005 @ 20:18 | Reply

  2. >Good idea. I keep forgetting about this (because it’s not present in other languages I’ve used), but it’s really handy to not have to escape quotes all the time!Thanks!

    Comment by newlisper — December 29, 2005 @ 21:42 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: