RSS feed
<< Planet killer | Home | Verizon's .002 cents >>

metaWeblog Droplet

This little vbs droplet serves as an example of how to use third party APIs to post to an online blog using XML-RPC. I tested it with pebble. To use it, copy the code below and save it as a vbs file. Change blogsite, username and password to match your needs. Drop some other file onto the vbs file, the script just requires SOMETHING to be dropped on it. You should see a new post posted on December 14, 2006 7:10:00 AM PST.

blogsite = "www.qicboy.com"
username = "secret"
password = "secret"
blogname = "default"

Dim http,fso,fin,xml

Set args = WScript.Arguments
If (args.count <1) then
  msgbox "Drop the file you wish to post.",0,"metaWeblog Droplet"


Else
  newPost(args(0))

End If

function newPost(ByVal path) 
  title="Sample title" 'read from file
  body ="Sample body"  'read from file
  pubDate = "20061214T07:10:00-0800" 'read from file

  document = "" &_
    "<methodCall>" &_
    "  <methodName>metaWeblog.newPost</methodName>" &_
    "  <params>" &_
    "    <param>" &_
    "      <value><string>" & blogname &"</string></value>" &_
    "    </param>" &_
    "    <param>" &_
    "      <value><string>" & username & "</string></value>" &_
    "    </param>" &_
    "    <param>" &_
    "      <value><string>" & password & "</string></value>" &_
    "    </param>" &_
    "    <param>" &_
    "      <value>" &_
    "        <struct>" &_
    "          <member>" &_
    "            <name>description</name>" &_
    "            <value><string>"& body & "</string></value>" &_
    "          </member>" &_
    "          <member>" &_
    "            <name>title</name>" &_
    "            <value><string>"& title &"</string></value>" &_
    "          </member>" &_
    "          <member>" &_
    "            <name>pubDate</name>" &_
    "            <value><dateTime.iso8601>" & pubDate & "</dateTime.iso8601></value>" &_
    "          </member>" &_
    "        </struct>" &_
    "      </value>" &_
    "    </param>" &_
    "    <param>" &_
    "      <value><boolean>1</boolean></value>" &_
    "   </param>" &_
    "  </params>" &_
    "</methodCall>"

  Set fso = createObject("Scripting.FileSystemObject")
  Set fin = fso.OpenTextFile(args.item(0), 1)
  set http = createObject("Microsoft.XMLHTTP")
  Set ie = createObject("InternetExplorer.Application")
  ie.Visible = True
  ie.statusText = "Opening page "& site &"..."
 
  http.open "POST", "http://" & blogsite & "/xmlrpc", false
  http.send (document)

  Set xml = createobject("msxml2.domdocument") 
  xml.loadxml http.responseText
  Set xsl = createobject("msxml2.domdocument") 
  xsl.load("res://msxml.dll/defaultss.xsl") 

  ie.Navigate "about:blank"
  ie.document.Write "<title>metaWeblog Droplet</title>"
  ie.document.Write xml.transformnode(xsl)

  ie.statusText = "Done"

  newPost = 0 
end function
Tags :



Add a comment Send a TrackBack
Home