Skip to content

Instantly share code, notes, and snippets.

@DxDiagDx
Last active May 3, 2021 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DxDiagDx/0eb27f26d4d8dd79407fe87379d23dc6 to your computer and use it in GitHub Desktop.
Save DxDiagDx/0eb27f26d4d8dd79407fe87379d23dc6 to your computer and use it in GitHub Desktop.
WordPress + Python: редактировать пост
import requests
import base64
url = "https://wholeblogs.com/wp-json/wp/v2/posts/"
postID = '1'
user = "your-username"
password = "your-application-password"
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
header = {'Authorization': 'Basic ' + token.decode('utf-8')}
post = {
'title': 'Hello World Updated',
'content': 'This is my first post created using rest API Updated'
}
responce = requests.post(url + postID, headers=header, json=post)
print(responce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment