2012-06-30 57 views
2

我使用Python編寫的followng WordPress的XML-RPC模塊:WordPress的XML-RPC的Python錯誤

但是當我運行該程序,我得到以下error.You對如何解決這個程序的任何想法?這裏是我得到的錯誤

Traceback (most recent call last): 
    File "<pyshell#28>", line 1, in <module> 
    wp.call(NewPost(post, True)) 
    File "C:\Python27\lib\site-packages\wordpress_xmlrpc\base.py", line 27, in call 
    raw_result = server_method(*args) 
    File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__ 
    return self.__send(self.__name, args) 
    File "C:\Python27\lib\xmlrpclib.py", line 1578, in __request 
    verbose=self.__verbose 
    File "C:\Python27\lib\xmlrpclib.py", line 1264, in request 
    return self.single_request(host, handler, request_body, verbose) 
    File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request 
    return self.parse_response(response) 
    File "C:\Python27\lib\xmlrpclib.py", line 1467, in parse_response 
    p.feed(data) 
    File "C:\Python27\lib\xmlrpclib.py", line 557, in feed 
    self._parser.Parse(data, 0) 
ExpatError: junk after document element: line 2, column 0 
+0

如果您提供產生此異常的調用,它會有所幫助... –

+0

uh ... self._parser.Parse(data,0) –

回答

2

當您對調用的響應不是有效的XML時,通常會發生此錯誤。例如,如果一開始就換行,像這樣:

\n<?xml version="1.0"?>\n<methodResponse>\n<params>\n<param>\n<value>\n 
<array><data>\n <value><string>wp.getUsersBlogs</string></value> 

的WordPress的某些版本(或已安裝的插件)似乎有這個問題。不幸的是,這意味着問題不在您的代碼中,而是與您正在與之通信的WordPress實例。