Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XMLRPC 'client' error
#11
No it did not work out.

sam@sam-H81M-S ~ $ python3 -m venv env
sam@sam-H81M-S ~ $ source ./env/bin/activate
(env) sam@sam-H81M-S ~ $ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from wordpress_xmlrpc import Client, WordPressPost
>>> from wordpress_xmlrpc.methods.taxonomies import *
>>> from wordpress_xmlrpc.methods.posts import *
>>> from wordpress_xmlrpc.methods.users import *
>>> from wordpress_xmlrpc.methods import *
>>> wp_url = "http://192.168.0.105:80/wordpress/xmlrpc.php"
>>> wp_username = 'admin'
>>> wp_password = '######'
>>> wp = Client(wp_url, wp_username, wp_password)
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/sam/env/lib/python3.5/site-packages/wordpress_xmlrpc/base.py", line 24, in __init__ self.supported_methods = self.server.mt.supportedMethods() File "/usr/lib/python3.5/xmlrpc/client.py", line 1092, in __call__ return self.__send(self.__name, args) File "/usr/lib/python3.5/xmlrpc/client.py", line 1432, in __request verbose=self.__verbose File "/usr/lib/python3.5/xmlrpc/client.py", line 1134, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python3.5/xmlrpc/client.py", line 1150, in single_request return self.parse_response(resp) File "/usr/lib/python3.5/xmlrpc/client.py", line 1322, in parse_response return u.close() File "/usr/lib/python3.5/xmlrpc/client.py", line 655, in close raise Fault(**self._stack[0]) xmlrpc.client.Fault: <Fault -32700: 'parse error. not well formed'> >>>
Quote:You need to put your port number in the URL.
How did you install the wordpress on your machine?

I installed Wordpress on my machine using LAMP stack from the command prompt on my Linux Mint 18.3. My localhost host address is 192.168.0.105 and my site is on 192.168.0.105/wordpress/. I dont know if sharing these IPs is considered good or bad so i've been changing 192.168.0.105 to 'localhost' when posting the outputs here.

I also did a
sudo netstat -ntlp
sam@sam-H81M-S ~ $ sudo netstat -ntlp
[sudo] password for sam: 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      1195/dnsmasq    
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      784/cupsd       
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      993/mysqld      
tcp6       0      0 :::80                   :::*                    LISTEN      1626/apache2    
tcp6       0      0 ::1:631                 :::*                    LISTEN      784/cupsd       
sam@sam-H81M-S ~ $ 
Reply
#12
Error:
xmlrpc.client.Fault: <Fault -32700: 'parse error. not well formed'>
This is strange.
This error raises when you pass an invalid XML character to the server.

Try to install sudo apt-get install php-xml -y && sudo service apache2 restart
Some guys had this same problem and solve it installing the php-xml package.
Reply
#13
That did solve the problem but I'm getting an error at wp.call now

(env) sam@sam-H81M-S ~ $ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from wordpress_xmlrpc import Client, WordPressPost
>>> from wordpress_xmlrpc.methods.taxonomies import *
>>> from wordpress_xmlrpc.methods.posts import *
>>> from wordpress_xmlrpc.methods.users import *
>>> from wordpress_xmlrpc.methods import *
>>> wp_url = "http://192.168.0.105:80/wordpress/xmlrpc.php"
>>> wp_username = 'admin'
>>> wp_password = '#####'
>>> wp = Client(wp_url, wp_username, wp_password)
>>> post = WordPressPost()
>>> post.title = 'My Post'
>>> post.content = 'This is content'
>>> post.id = 1
>>> wp.call(WordPressPost(post))
Error:
Traceback (most recent call last): File "/home/sam/env/lib/python3.5/site-packages/wordpress_xmlrpc/wordpress.py", line 32, in __init__ converted_value = self._def[key].convert_to_python(xmlrpc) File "/home/sam/env/lib/python3.5/site-packages/wordpress_xmlrpc/fieldmaps.py", line 29, in convert_to_python return xmlrpc.get(self.name, self.default) AttributeError: 'WordPressPost' object has no attribute 'get' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/sam/env/lib/python3.5/site-packages/wordpress_xmlrpc/wordpress.py", line 35, in __init__ raise FieldConversionError(key, e) wordpress_xmlrpc.exceptions.FieldConversionError: post_status >>>
Reply
#14
Try this:

>>> from wordpress_xmlrpc import Client, WordPressPost
>>> from wordpress_xmlrpc.methods.taxonomies import *
>>> from wordpress_xmlrpc.methods.posts import *
>>> from wordpress_xmlrpc.methods.users import *
>>> from wordpress_xmlrpc.methods import *
>>> wp_url = "http://192.168.0.105:80/wordpress/xmlrpc.php"
>>> wp_username = 'admin'
>>> wp_password = '#####'
>>> wp = Client(wp_url, wp_username, wp_password)
>>> post = WordPressPost()
>>> post.title = 'My Post'
>>> post.content = 'This is content'
>>> post.id = 1
>>> wp.call(NewPost(post))
Reply
#15
That worked! I checked the site and the post is saved as draft with the title and content i inputted.

I'm unsure what the number after wp.call is though

Output:
>>> wp.call(NewPost(post)) '7' >>>
It showed '5' the first time I created this post. When i moved that to trash and recreated it shows 7
Reply
#16
I think this is the ID of the new post.

So, is better to use it like this:
post.id = wp.call(NewPost(post))
Reply
#17
Thank you! That worked perfectly. Honestly thank you so much for helping me.
Reply
#18
Nice, you're welcome!
I learned something new too.
Reply
#19
(Jul-03-2018, 05:06 PM)SamLearnsPython Wrote: I dont know if sharing these IPs is considered good or bad so i've been changing [the ip address] to 'localhost' when posting the outputs here.

I don't think it matters since that's your local ip address. That address isn't publicly available, and only exists behind your router. It should be no surprise to anyone that your local address is "192.168.0.NNN". The only thing we can guess by seeing that, is that you have 5-6 internet enabled devices, possibly more (computers, tvs, game consoles, tablets, cell phones, etc), and that isn't really meaningful info either.
Reply
#20
(Jul-03-2018, 09:17 PM)nilamo Wrote:
(Jul-03-2018, 05:06 PM)SamLearnsPython Wrote: I dont know if sharing these IPs is considered good or bad so i've been changing [the ip address] to 'localhost' when posting the outputs here.

I don't think it matters since that's your local ip address. That address isn't publicly available, and only exists behind your router. It should be no surprise to anyone that your local address is "192.168.0.NNN". The only thing we can guess by seeing that, is that you have 5-6 internet enabled devices, possibly more (computers, tvs, game consoles, tablets, cell phones, etc), and that isn't really meaningful info either.

Good to know this! Thank you for the info
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting "SSL client not supported by this Python installation" error prabirsarkar 0 915 Mar-13-2023, 05:01 PM
Last Post: prabirsarkar
  How to use xmlrpc from flrig? mamoman 3 1,061 Feb-10-2023, 06:25 PM
Last Post: Larz60+
  Error in Mysql Client when upgrading Django Abi 0 1,851 Sep-21-2020, 06:11 AM
Last Post: Abi
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 4,823 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  wordpress-python-xmlrpc. I can import 1 file. How do I import the entire folder? SamLearnsPython 0 3,234 Jul-05-2018, 06:21 AM
Last Post: SamLearnsPython
  xmlrpc.client, ServerProxy and null return thepurpleblob 0 3,021 Oct-26-2017, 10:26 AM
Last Post: thepurpleblob
  Error connecting to client rajeev1729 2 8,557 Sep-15-2017, 10:34 AM
Last Post: rajeev1729

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020