一、背景

wordpress带有一个功能,就是使用xmlrpc发布文章。这样子就可以在一些常用的博客客户端中编辑文章,然后提交到wordpress的网站上去。而不需要每次都打开浏览器进行文章编辑。我使用python的是 python的wordpress_xmlrpc模块。但是写好代码运行的时候报错了。

二、错误详情

Traceback (most recent call last):
  File "wordpress.py", line 13, in <module>
    wp = Client('http://ddghgfh.cn/xmlrpc.php', 'sgh4gsd37', 'gsdhgshhb1')
  File "/home/ubuntu/.local/lib/python2.7/site-packages/wordpress_xmlrpc/base.py", line 24, in __init__
    self.supported_methods = self.server.mt.supportedMethods()
  File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1283, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1316, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1493, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 800, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -32700: 'parse error. not well formed'>

三、错误原因

php中缺少相应的xml模块。

四、解决办法

  1. 查看php版本
php -v
#输出
PHP 7.2.7-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Jun 22 2018 09:13:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.7-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
  1. 搜索模块
sudo apt-cache search php |grep xml
#输出
libsmokeqtxml4-3 - Qt Xml SMOKE library
libsmokeqtxmlpatterns4-3 - Qt XmlPatterns SMOKE library
php5-xmlrpc - XML-RPC module for php5
php-horde-xml-element - Horde Xml Element object
php-horde-xml-wbxml - Horde_Xml_Wbxml provides an API for encoding and decoding WBXML documents used in SyncML and other wireless applications
php-xml-dtd - Parsing of DTD files and DTD validation of XML files
php-xml-htmlsax3 - SAX parser for HTML and other badly formed XML documents
php-xml-parser - PHP PEAR module for parsing XML
php-xml-rpc - PHP implementation of the XML-RPC protocol
php-xml-rpc2 - PHP XML-RPC client/server library
php-xml-rss - php based parser for RSS news feeds
php-xml-serializer - swiss-army knife for reading and writing XML files
wulflogger - extract cluster node data from remote xmlsysd daemons
xmlsysd - wulfware daemon to extract data from cluster nodes
php7.0-xmlrpc - XMLRPC-EPI module for PHP
php-xmlrpc - XMLRPC-EPI module for PHP [default]
php5.6-xmlrpc - XMLRPC-EPI module for PHP
php5.6-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.0-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.1-xmlrpc - XMLRPC-EPI module for PHP
php7.2-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.2-xmlrpc - XMLRPC-EPI module for PHP
  1. 根据版本安装相应的模块(我的是php7.2)
sudo apt-get install php7.2-xml
sudo apt-get install php7.2-xmlrpc

参考资料

github上的讨论





http://xzh.i3geek.com

爱唠叨的老鱼

爱唠叨的老鱼

技术经理,个人站长,创业者

0 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据