WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

XML
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Calling Blogger API with XML-RPC from WinBatch


Question:

Here's a nice challenge for someone more knowledgeable than me. :)

I'm on a mission to send posts to a Blogger.com blog using their API through WinBatch, and I'm very stuck at the moment -- hoping someone might be kind enough to lend a hand.

Calls to the API are done via XML-RPC, and they give examples of the XML-RPC calls to use for each function, and the URI they should 'go to' (http://plant.blogger.com/api/RPC2).

Here is an example of a function call they give -- you can see the page at http://www.blogger.com/developers/api/1_docs/xmlrpc_newPost.html :-

<?xml version="1.0"?>
<methodCall>
<methodName>blogger.newPost</methodName>
<params>
<param><value><string>C6CE3FFB3174106584CBB250C0B0519BF4E294</string></value></param>
<param><value><string>744145</string></value></param>
<param><value><string>ewilliams</string></value></param>
<param><value><string>secret</string></value></param>
<param><value><string>Today I had a peanut butter and pickle sandwich
for lunch. Do you like peanut-butter and pickle sandwiches? I do. 
They're yummy. Please comment!</string></value></param>
<param><value><boolean>false</boolean></value></param> 
</params>
</methodCall>
I'm assuming I have to construct a string containing the above function call and 'send' it to that URI.

There are two things I'm confused about.

[1] Whether or not I have to include the 'header' section as in their example:

POST /api/RPC2 HTTP/1.0
User-Agent: Java.Net Wa-Wa 2.0
Host: plant.blogger.com
Content-Type: text/xml
Content-length: 515
...which is the bit before the XML tags start. OR if this data should be put in whatever WinBatch function I have to use to make this work.

and

[2] How I would go about 'sending' this to the URI they provide, using WinBatch?

(I'm not worried about the parameters within the XML, I think I've got those sorted okay.)

I'm sure there must be someone reading this who knows exactly what I should be doing here! Any help would be very much appreciated.

Answer:

okay I got this to send XML and get back a response, using MSXML that comes with MSIE 5+ and Winbatch.

Note: I just don't have the credentials and am new to using XMLHTTP...

xfile = "C:\Jay\xml\Blogger_New_Post.xml"  ;<-- cut & paste the sample XML they supplied...
xmldoc = ObjectOpen("Microsoft.XMLDOM")
xmldoc.async = @FALSE
xmldoc.load(xfile)

xmlhttp = ObjectOpen("Msxml2.XMLHTTP.3.0")
xmlhttp.Open("POST", "http://plant.blogger.com/api/RPC2", @FALSE, "userid", "password")
xmlhttp.Send(xmldoc)

response = xmlhttp.responseXML.xml
ClipPut(response)
Message("Debug", response)

Exit
and the response XML...

<?xml version="1.0"?>
<methodResponse><fault><value><struct><member><name>faultString
</name><value>com.pyra.blogger.api.UserNotAuthorizedException: We're sorry but the 
Username/Password combination you've entered is either invalid or you don't have 
permission to access this Blog. 
</value>
</member><member><name>faultCode
</name><value><int>0
</int>
</value>
</member>
</struct>
</value>
</fault>
</methodResponse>

Article ID:   W17338
File Created: 2007:07:03:14:29:32
Last Updated: 2007:07:03:14:29:32