im trying to connect to my local website, which i setup using wampserver, i can connect to it via browser. However, when i try to connect to it via python:
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_site = Client("http://localhost/testwp/", "my wp username", "my wp password")
i get the error:
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 3, column 29
is it even possible to connect to a local server using xml-rpc, or what am i doing wrong?
thank you!
It's possible to connect to a local wp server using python-wordpress-xmlrpc
library.
According to official docs in order to do so, we need to access xmlrpc.php file in the root wp directory while setting up the connection. In the snippet provided in the original question consider changing the last line to:
wp_site = Client("http://localhost/testwp/xmlrpc.php", "my wp username", "my wp password")
.
Possible sample code to get User info might look like so:
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_site = Client("http://localhost/testwp/xmlrpc.php", "my_wp_username", "my_wp_password")
user_info = wp_site.call(GetUserInfo())
print(user_info)