{"id":976,"date":"2009-10-19T18:23:58","date_gmt":"2009-10-19T16:23:58","guid":{"rendered":"http:\/\/www.juust.org\/?p=976"},"modified":"2024-10-13T17:04:53","modified_gmt":"2024-10-13T15:04:53","slug":"more-vba-and-wordpress-xml-rpc","status":"publish","type":"post","link":"https:\/\/www.juust.org\/index.php\/more-vba-and-wordpress-xml-rpc\/2009\/10\/","title":{"rendered":"more vba and wordpress xml rpc"},"content":{"rendered":"<p>Basic Example II, vba wordpress remote control, demo.ayHello is fun but quite useless, so let&#8217;s proceed to wp.getUsersBlogs. <\/p>\n<p>I make a table in access (id, isAdmin, blogid, url, blogName, xmlrpc) and then query wordpress, parse the xml response in store it in the database.<\/p>\n<p>So here we go query WordPress :<\/p>\n<pre lang=\"vb\">\r\n    methodname = \"wp.getUsersBlogs\"\r\n\r\n'xmlrpc url\r\n    txtURL = \"http:\/\/www.blog.com\/xmlrpc.php\"\r\n\r\n'authorization\r\n    txtUserName = \"user\"\r\n    txtPassword = \"pass\"\r\n\r\n'XML http request  \r\n    Dim objSvrHTTP As ServerXMLHTTP\r\n    Dim strT As String\r\n    Set objSvrHTTP = New ServerXMLHTTP\r\n    \r\n    objSvrHTTP.Open \"POST\", txtURL, False, CStr(txtUserName), _\r\n     CStr(txtPassword)\r\n    \r\n    objSvrHTTP.setRequestHeader \"Accept\", \"application\/xml\"\r\n    objSvrHTTP.setRequestHeader \"Content-Type\", \"application\/xml\"\r\n\r\n'here is the bit with the wp.getUserBlogs methodname, \r\n'and the username and password    \r\n    strT = \"\"\r\n    strT = strT & \"<methodcall>\"\r\n    strT = strT & \"<methodname>\" & methodname & \"<\/methodname>\"\r\n    strT = strT & \"<params>\"\r\n    strT = strT & \"<param \/><value><string>\" & txtUserName & \"<\/string><\/value>\"\r\n    strT = strT & \"<param \/><value><string>\" & txtPassword & \"<\/string><\/value>\"\r\n    strT = strT & \"<\/params>\"\r\n    strT = strT & \"<\/methodcall>\"\r\n    \r\n    objSvrHTTP.send strT\r\n\r\n<\/pre>\n<p>that&#8217;s pretty straight forward.<\/p>\n<p>I get an xml message back with the data stored in an array of STRUCT types.<\/p>\n<pre lang=\"vb\">\r\n'Create the DomDocument Object\r\nDim oDoc As MSXML2.DOMDocument\r\nSet oDoc = CreateObject(\"MSXML2.DOMDocument\")\r\noDoc.async = False\r\noDoc.validateOnParse = False\r\n\r\n'Load the response in the DomDocument Object\r\nDim fSuccess As Boolean\r\nfSuccess = oDoc.loadXML(objSvrHTTP.responseText)\r\nIf Not fSuccess Then\r\n    MsgBox \"failed\"\r\n    Exit Function\r\nEnd If\r\n        \r\n'counters\r\nct = 1\r\ncs = 1\r\n\r\n'array to story the field values\r\nDim SArray(1 To 5) As String\r\n\r\n'open the table as recordset \r\nDim d As DAO.Recordset\r\nSet d = CurrentDb.OpenRecordset(\"blogs\", dbOpenTable)\r\n\r\n'lets get the structs\r\nSet oChildren = oDoc.selectNodes(\"\/\/struct\")\r\nFor Each oStruct In oChildren\r\n\r\n'the struct has members, \r\n\r\n   Set Members = oStruct.childNodes\r\n   For Each Member In Members\r\n\r\n'each member has a param pair (field, value)\r\n'skip the first param, and store the field value\r\n'in an array\r\n\r\n       Set Params = Member.childNodes\r\n       For Each Param In Params\r\n            ct = ct + 1\r\n            If ct \/ 2 <> Int(ct \/ 2) Then\r\n                SArray(ct \/ 2) = Param.Text\r\n                cs = cs + 1\r\n            End If\r\n       Next\r\n\r\n    Next\r\n\r\n    'we got the struct data, \r\n    'now add the array to the database\r\n    \r\n     With d\r\n        .AddNew\r\n        !isAdmin = SArray(1)\r\n        !url = SArray(2)\r\n        !blogid = SArray(3)\r\n        !blogName = SArray(4)\r\n        !xmlrpc = SArray(5)\r\n        .Update\r\n    End With\r\n\r\nNext\r\n\r\n'close up shop\r\nd.Close\r\nSet d = Nothing\r\n\r\nEnd Function\r\n\r\n<\/pre>\n<p>The other worpdress api calls work quite the same. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basic Example II, vba wordpress remote control, demo.ayHello is fun but quite useless, so let&#8217;s proceed to wp.getUsersBlogs. I make a table in access (id, isAdmin, blogid, url, blogName, xmlrpc) and then query wordpress, parse the xml response in store it in the database. So here we go query WordPress : methodname = &#8220;wp.getUsersBlogs&#8221; &#8216;xmlrpc [&hellip;]<\/p>\n","protected":false},"author":5796,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[500,13,22],"tags":[42],"class_list":["post-976","post","type-post","status-publish","format-standard","hentry","category-vba","category-wordpress","category-xml-rpc","tag-vba"],"_links":{"self":[{"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/posts\/976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/users\/5796"}],"replies":[{"embeddable":true,"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/comments?post=976"}],"version-history":[{"count":1,"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/posts\/976\/revisions"}],"predecessor-version":[{"id":12754,"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/posts\/976\/revisions\/12754"}],"wp:attachment":[{"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/media?parent=976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/categories?post=976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.juust.org\/index.php\/wp-json\/wp\/v2\/tags?post=976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}