Created
September 25, 2022 22:36
-
-
Save rahulbanerjee26/47e8fa7fa99d45f1aff6cab8c6a71676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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