PACKAGE

import json
import requests
import pymysql

FUNCTION

def functionName(url, auth, title, content):
    body = {
      'title': title,
      'content': content,
      'status': 'publish'
    }

    headers = {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
      'Authorization': 'Basic {}'.format(auth),
    }

    # response
    post = requests.post(url, data=json.dumps(body), headers=headers)
    response = json.loads(post.content)
    return response['link']

포스트맨에서 'auth' 얻는 방법

포스트맨 다운로드 링크: https://www.getpostman.com/downloads/

캡처.jpg


캡처.jpg

REFERENCE

  1. url = 워드프레스 주소 + /wp-json/wp/v2/posts