Я пытаюсь опубликовать sh сообщение непосредственно в wordress, как описано в следующей ссылке: insert d https://medium.com/analytics-vidhya/wordpress-rest-api-with-python-f53a25827b1c
Я установил плагин Wordpress «Пароли приложений».
Но с этот код Python, у меня ошибка 401:
import requests
import json
import base64
url = "http://xxxxx.com/wp-json/wp/v2/posts"
user = "adminxxxx"
password = "xxxxx xxxxx "
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
header = {'Authorization': 'Basic ' + token.decode('utf-8')}
post = {
'title' : 'Post',
'status' : 'publish',
'content' : 'This is my first post created using rest API',
'categories': 1, # category ID
'date' : '2020-08-01T10:00:00'
}
response = requests.post(url , headers=header, json=post)
print(response)
http://xxxxx.com/wp-json/wp/v2/posts в порядке.
Возможно, защита пароля (base64) не подходит? О чем вы думаете? Большое спасибо? Тео