Question

I'm using xml-rpc to upload post on my wordpress site already one month, but yesterday I got error message.

Response from server does not contain valid XML.

I did reinstall my wordpress site, but the same problem still remains. I think my code is correct because it would work for about 1 month. Check this code list:

   Public Structure category
    Public categoryId As Object
    Public parentId As Object
    Public description As Object
    Public categoryName As Object
    Public htmlUrl As Object
    Public rssUrl As Object
End Structure
<XmlRpcUrl("http://nullgames.com/xmlrpc.php")> _
   Public Interface IWP
    Inherits IXmlRpcProxy

    <XmlRpcMethod("wp.getCategories")> _
    Function getCategories(ByVal args() As String) As category()
End Interface
Public Structure blogInfo

    Public title As String
    Public description As String
    Public mt_keywords As String()
    Public categories As String()

End Structure

Public Interface IgetCatList
    <CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")> _
    Function NewPage(ByVal blogId As Integer, ByVal strUserName As String, ByVal strPassword As String, ByVal content As blogInfo, ByVal publish As Integer) As String
End Interface

Sub SendPost(ByVal titlepost_ As String, ByVal bodypost_ As String, ByVal categorypost_ As String)
    Dim proxy As IWP = XmlRpcProxyGen.Create(Of IWP)()
    Dim args() As String = {"http://nullgames.com", "Admin", "xxxxxxxxx"} 
    Dim categories2() As category
    categories2 = proxy.getCategories(args)
    For Each category In categories2
        Debug.Print(category.categoryId)
        Debug.Print(category.categoryName)
        Debug.Print(category.description)
        Debug.Print(category.htmlUrl)
        Debug.Print(category.rssUrl)
    Next
    Dim result As String = Nothing
    Dim newBlogPost As blogInfo = Nothing
    Dim categories = CType(XmlRpcProxyGen.Create(GetType(IgetCatList)), IgetCatList)
    Dim clientProtocol = CType(categories, XmlRpcClientProtocol)
    clientProtocol.Url = "http://nullgames.com/xmlrpc.php"

    newBlogPost.title = titlepost_
    newBlogPost.description = bodypost_
    newBlogPost.mt_keywords = New String() {p_tags}
    newBlogPost.categories = New String() {categorypost_}
    result = ""
    Try
        result = categories.NewPage(1, "Admin", "xxxxxxxxx", newBlogPost, 1)
        idPost = result
    Catch ex As Exception
        MessageBox.Show(ex.Message)
     End Try
End Sub

When I tried to view the args() I got this reply:

The XML page cannot be displayed 

Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.

Invalid at the top level of the document. Error processing resource 'file:///C:/Users/owner/AppData/Local/Temp/VSD1.tmp.XML...

http://nullgames.com ^

Moreover, I use the same code in my other wordpress site and that one works fine..., any idea?

Was it helpful?

Solution

The problem is solved, if you have the same problem with me, try this:

  1. check the xmlrpc.php is valid in your domain with (http://example.com/xmlrpc.php) or (http://www.example.com/xmlrpc.php)
  2. Deactive all plugin one by one and run again your program so you know if plugin that installed in your site is affect error or not, (my site get error in xmlrpc because install worst plugin)
  3. if the problem is still occurs, try change your wordpress theme. (code in your theme may cause error (like function.php etc.))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top