Last active
September 4, 2019 00:52
-
-
Save markis/48a71a0fbe71a3996cf8167e48b0bcc9 to your computer and use it in GitHub Desktop.
Simplest example of creating chat post using praw
This file contains hidden or 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
from praw import Reddit | |
# Get a Reddit instance | |
# https://praw.readthedocs.io/en/latest/code_overview/reddit_instance.html# | |
reddit = Reddit( | |
client_id="<client_id>", | |
client_secret="<client_secret>", | |
username="<user>", | |
password="<password>", | |
user_agent="Script by /u/markis", | |
) | |
# Make direct post against the API | |
# https://praw.readthedocs.io/en/latest/code_overview/reddit_instance.html#praw.Reddit.post | |
reddit.post('api/submit/', data={ | |
"sr": "<subreddit_name>", | |
"kind": "self", | |
"resubmit": True, | |
"sendreplies": True, | |
"title": "<post title>", | |
"text": "<post text>", | |
"nsfw": False, | |
"spoiler": False, | |
# This will make the post a chat-post | |
"discussion_type": "CHAT", | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment