

That’s the next thing we have done in the above function. If you use twitter very frequently then you know that how disgusting long links look like so in order to tackle that we are using goo.gl to generate short links for us. This is used to track which posts we have already grabbed.Īfter that we are looping over the posts and appending values to the dictionary and the list. Print " Generating short link using goo.gl"įirst of all we are declaring a dictionary to hold the post title and link and after that we are making a list to hold the unique ids of every post that we grab.

def tweet_creator(subreddit_info):įor submission in subreddit_info.get_hot(limit=20): So now we have to define a function that gets the list of posts and there urls from Reddit for us. This method connects with Reddit and gets the subreddit of our choice and then returns that subreddit for us to work further with. R = praw.Reddit('yasoob_python reddit twitter bot ' Print " setting up connection with Reddit" Now we have to initiate connection with Reddit. First of all we will have to import the required libraries and set up some basic variables: import prawĪccess_token_secret = 'YOUR ACCESS TOKEN SECRET HERE'Ĭonsumer_secret = 'YOUR CONSUMER SECRET HERE' You will have to edit the permissions for your app under the settings tab and grant your application read and write permission. So first of all you will have to register an app on and after registering copy the

What this bot will do is that it will copy post titles and url from any subreddit that you want and then it will post them to twitter keeping the 140 characters length in mind.įirstly let me tell you what Reddit is. In this post I am going to teach you how we can make a Reddit + Twitter bot. Source Making a Reddit + twitter Bot September 14, 2013
