juust ~ php oddities

Unordered list of one element
  • rss
  • begin
  • about
    • vcard
    • WTF is BroJesus
  • php scripts
    • flickr wp widget
    • google multi key serp tool, php script
    • gwt plugin
  • php classes
    • php pagerank class
    • fibonacci class
    • robots.txt parser php class
  • serp
    • serp dashboard wordpress plugin
  • services

more vba and wordpress xml rpc

juust | 19/10/2009

Basic Example II, vba wordpress remote control, demo.ayHello is fun but quite useless, so let’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 :

  1.     methodname = "wp.getUsersBlogs"
  2.  
  3. 'xmlrpc url
  4.     txtURL = "http://www.blog.com/xmlrpc.php"
  5.  
  6. 'authorization
  7.     txtUserName = "user"
  8.     txtPassword = "pass"
  9.  
  10. 'XML http request  
  11.     Dim objSvrHTTP As ServerXMLHTTP
  12.     Dim strT As String
  13.     Set objSvrHTTP = New ServerXMLHTTP
  14.    
  15.     objSvrHTTP.Open "POST", txtURL, False, CStr(txtUserName), _
  16.      CStr(txtPassword)
  17.    
  18.     objSvrHTTP.setRequestHeader "Accept", "application/xml"
  19.     objSvrHTTP.setRequestHeader "Content-Type", "application/xml"
  20.  
  21. 'here is the bit with the wp.getUserBlogs methodname,
  22. 'and the username and password    
  23.     strT = ""
  24.     strT = strT & "<methodcall>"
  25.     strT = strT & "<methodname>" & methodname & "</methodname>"
  26.     strT = strT & "<params>"
  27.     strT = strT & "<param><value><string>" & txtUserName & "</string></value></param>"
  28.     strT = strT & "<param><value><string>" & txtPassword & "</string></value></param>"
  29.     strT = strT & "</params>"
  30.     strT = strT & "</methodcall>"
  31.    
  32.     objSvrHTTP.send strT

that’s pretty straight forward.

I get an xml message back with the data stored in an array of STRUCT types.

  1. 'Create the DomDocument Object
  2. Dim oDoc As MSXML2.DOMDocument
  3. Set oDoc = CreateObject("MSXML2.DOMDocument")
  4. oDoc.async = False
  5. oDoc.validateOnParse = False
  6.  
  7. 'Load the response in the DomDocument Object
  8. Dim fSuccess As Boolean
  9. fSuccess = oDoc.loadXML(objSvrHTTP.responseText)
  10. If Not fSuccess Then
  11.     MsgBox "failed"
  12.     Exit Function
  13. End If
  14.        
  15. 'counters
  16. ct = 1
  17. cs = 1
  18.  
  19. 'array to story the field values
  20. Dim SArray(1 To 5) As String
  21.  
  22. 'open the table as recordset
  23. Dim d As DAO.Recordset
  24. Set d = CurrentDb.OpenRecordset("blogs", dbOpenTable)
  25.  
  26. 'lets get the structs
  27. Set oChildren = oDoc.selectNodes("//struct")
  28. For Each oStruct In oChildren
  29.  
  30. 'the struct has members,
  31.  
  32.    Set Members = oStruct.childNodes
  33.    For Each Member In Members
  34.  
  35. 'each member has a param pair (field, value)
  36. 'skip the first param, and store the field value
  37. 'in an array
  38.  
  39.        Set Params = Member.childNodes
  40.        For Each Param In Params
  41.             ct = ct + 1
  42.             If ct / 2 <> Int(ct / 2) Then
  43.                 SArray(ct / 2) = Param.Text
  44.                 cs = cs + 1
  45.             End If
  46.        Next
  47.  
  48.     Next
  49.  
  50.     'we got the struct data,
  51.     'now add the array to the database
  52.    
  53.      With d
  54.         .AddNew
  55.         !isAdmin = SArray(1)
  56.         !url = SArray(2)
  57.         !blogid = SArray(3)
  58.         !blogName = SArray(4)
  59.         !xmlrpc = SArray(5)
  60.         .Update
  61.     End With
  62.  
  63. Next
  64.  
  65. 'close up shop
  66. d.Close
  67. Set d = Nothing
  68.  
  69. End Function

The other worpdress api calls work quite the same.

Categories
wordpress, xml-rpc
Comments rss
Comments rss
Trackback
Trackback

« wordpress xmlrpc and microsoft access vba integrating ms office and wordpress with vba and xml-rpc »

Leave a Reply

Click here to cancel reply.

Recent Posts

  • geert wilders
  • gone till september
  • socialize me
  • Pagerank sculpting session
  • wish you were here

click me!
rss
Comments rss
Blog Directory
Web Developement Blogs - BlogCatalog Blog Directory
Listed in LS Blogs the Blog Directory and Blog Search Engine
Blog Flux Directory
joopita.com free web directory and search engine
design by jide
sitemap
22258 confirmed spam kills