On Mar 7, 2006, at 7:36 PM, Brad Rhine wrote:

I'm also interested to learn how to post to Blogger and WP and don't
know where/how to start even fater reading the "RFC: MetaWeblog API"
:)

I'm off to a meeting right now, but I'll try to post some sample code later tonight.

OK, here we go. Here's a function that will format your xmlrpc request for entering a new post. Watch for line wraps. This function assumes you're passing in the BlogID, username, password, post title, and post content. Getting that stuff is left as an exercise for the reader. :)

======================
Function metaWeblogNewPost(myBlogID as string, myUsername as string, myPassword as string, myTitle as string, myBody as string) As string

  dim xmlString as string
  xmlString="<?xml version=""1.0""?>"
xmlString=xmlString+"<methodCall><methodName>metaWeblog.newPost</ methodName><params>"
  xmlString=xmlString+"<param><value><string>"
  xmlString=xmlString+myBlogID
  xmlString=xmlString+"</string></value></param>"
  xmlString=xmlString+"<param><value><string>"
  xmlString=xmlString+myUsername
  xmlString=xmlString+"</string></value></param>"
  xmlString=xmlString+"<param><value><string>"
  xmlString=xmlString+myPassword
  xmlString=xmlString+"</string></value></param>"
  xmlString=xmlString+"<param><value><struct>"
xmlString=xmlString+"<member><name>title</name><value>"+prepForHTML (myTitle)+"</value></member>" xmlString=xmlString+"<member><name>description</ name><value>"+prepForHTML(myBody)
  xmlString=xmlString+"</value></member>"
xmlString=xmlString+"</struct></value></ param><param><value><boolean>"
  xmlString=xmlString+"1"
xmlString=xmlString+"</boolean></value></param></params></ methodCall>"
  return xmlString

End Function
======================

Once you have the request properly formatted, you send it to the rpc host via an HTTPSocket. So, assuming you've formatted the request and stuck into a variable called "PostData", you can do this.

  MySocket.SetPostContent(postData,"text/xml")
  MySocket.Post "http://myserver.com/path-to-xmlrpc-stuff";

This is all very quick and dirty, and I haven't checked for errors or anything, but hopefully it'll give you the basic idea.

--
Brad Rhine
[EMAIL PROTECTED]
http://bradrhine.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to