Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created September 25, 2022 22:36
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 rahulbanerjee26/47e8fa7fa99d45f1aff6cab8c6a71676 to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/47e8fa7fa99d45f1aff6cab8c6a71676 to your computer and use it in GitHub Desktop.
def create_post_medium(
self,
title,
content,
publish_status="draft",
contentFormat="html",
tags=[],
notifyFollowers = False,
canonicalUrl=None
):
data = {
'title': title,
'content': content,
'publishStatus': publish_status,
'contentFormat': contentFormat,
'tags': tags,
'notifyFollowers': notifyFollowers
}
if canonicalUrl:
data['canonicalUrl'] = canonicalUrl
response = self._session.post(
f"{self._endpoint}users/{self._userID}/posts",
data=data)
return response.json()['data']['url']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment