Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
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.
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.
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.
; okay I got this to send XML and get back a response, using ; MSXML that comes with MSIE 5+ and Winbatch. ; 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>
Here is the code that works:
#DefineSubRoutine PostToBlogger(blogID,userName,password,content) AddExtender("WWINT34I.DLL") ;WinInet host= "www.blogger.com" mainurl= "/api" xmlfile= "E:\NAPS\Blog&Ping\xml.txt" rsltfile= "E:\NAPS\Blog&Ping\PostToBlogger.txt" xml=FileGet(xmlfile) appkey="put your app key here!" ;Replace my tags here xml=StrReplace(xml,"{{APPKEY}}",appkey) xml=StrReplace(xml,"{{BLOGID}}",blogID) xml=StrReplace(xml,"{{USERNAME}}",username) xml=StrReplace(xml,"{{PASSWORD}}",password) xml=StrReplace(xml,"{{CONTENT}}",content) tophandle=iBegin(0,"","") connecthandle=iHostConnect(tophandle, host, @HTTP, "", "") datahandle=iHttpInit(connecthandle,"POST",mainurl,"", 0) rslt=iHttpOpen(datahandle, 0, xml, -1); ;Error? Display HTTP headers If rslt!=200 headers=iHttpHeaders(datahandle) AskItemlist("Rslt=%rslt%",headers,@TAB,@UNSORTED,@SINGLE) EndIf xx=iReadData(datahandle,rsltfile) iClose(datahandle) iClose(connecthandle) iClose(tophandle) #EndSubRoutineAnd the contents of my XML file (angled open brackets changed):-
<?xml Version="1.0"?> <methodCall> <methodName>blogger.newPost</methodName> <params> <param><value><STRING>{{APPKEY}}</STRING></value></param> <param><value><STRING>{{BLOGID}}</STRING></value></param> <param><value><STRING>{{USERNAME}}</STRING></value></param> <param><value><STRING>{{PASSWORD}}</STRING></value></param> <param><value><STRING>{{CONTENT}}</STRING></value></param> <param><value><boolean>1</boolean></value></param> </params> </methodCall>What ISN'T working like a charm is my effort to automate an HTTP POST request to http://rpc.pingomatic.com/ so that I can ping my blog entry from within my program as well. (Actually, I've just posted a new thread asking for help!) I believe the HTTP headers that Winbatch sends out are disliked by the receiving server. Actually, I tried with your alternative methods of posting, and the headers were still wrong for what I believe the receiving server needs. :(
Interestingly, posting to the blog URL was fine, even though the headers were different to what the XML-RPC specification says they should be - perhaps Blogger.com's RPC server is lenient on the headers.
Article ID: W17342
File Created: 2007:07:03:14:29:32
Last Updated: 2007:07:03:14:29:32