我使用的是用python编写的followng wordpress xmlrpc模块:
但是当我运行程序时,我得到以下错误。你知道如何解决这个程序吗?这是我得到的错误
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 :(得分: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实例。