{"id":1000,"date":"2014-06-13T12:27:15","date_gmt":"2014-06-13T12:27:15","guid":{"rendered":"http:\/\/www.silkstream.net\/blog\/?p=1000"},"modified":"2014-09-05T14:56:52","modified_gmt":"2014-09-05T14:56:52","slug":"retweeting-with-your-twython-twitter-bot","status":"publish","type":"post","link":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html","title":{"rendered":"Noob&#8217;s Guide #2:  ReTweeting with your Twython Twitter Bot"},"content":{"rendered":"<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1002\" alt=\"Noob Guide to Twython\" src=\"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/noob-guide-twython-2.jpg\" width=\"556\" height=\"300\" \/><\/p>\n<p style=\"text-align: justify;\">Last week in this Noob&#8217;s Guide to Twython we covered <a title=\"Setting Up Twython\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/how-to-get-going-with-twython.html\" target=\"_blank\">setting up your Twython for the first time<\/a> (installing Twython, authenticating with the Twitter API, and Tweeting your first Tweet from Twython). Now we&#8217;re going to begin exploring how you can use your Twitter bot to ReTweet.<\/p>\n<h2 style=\"text-align: justify;\">Reasons to ReTweet<\/h2>\n<p style=\"text-align: justify;\">Though\u00a0the very idea of having a bot automatically ReTweeting things has been corrupted by the mindless Twitter accounts that distribute nothing but spam, the use of a ReTweet bot is not actually against any of Twitter&#8217;s terms and conditions. If executed correctly. This is because there&#8217;s a whole wealth of value to having a ReTweet bot.<\/p>\n<p style=\"text-align: justify;\">All Twitter cares about is spam. But when not performed for spam, a ReTweet can be a powerful thing. It can be used to promote certain events or news across a wider audience. People&#8217;s incentive to follow a ReTweet bot may be to receive Tweets regarding a subject, but wouldn&#8217;t want to Follow the original poster on Twitter as they are only interested in very specific Tweets and not everything that user has to say. People can use the hashtag ReTweet bots to follow the hashtag within their stream, so they don&#8217;t have to access it via a separate search just to browse.<\/p>\n<p style=\"text-align: justify;\">Other automated ReTweet possibilities could include anyone mentioning your domain or brand name. Of course, you would\u00a0<em>definitely<\/em> have to create a negative keyword list to filter out any negative sentiment being expressed toward your brand. Wouldn&#8217;t want to be ReTweeting abusive messages about yourself! How unfortunate would that be!<\/p>\n<p style=\"text-align: justify;\">ReTweets are a great method of content discovery, and I can&#8217;t tell you how many times I&#8217;ve Followed users from seeing a ReTweet of their status. Their Tweet gained my interest, I checked it out and it inspired me to Follow them for more! Similarly, if there&#8217;s a big event going on with a promoted hashtag, you could have each Tweet containing that hashtag automatically be ReTweeted via your account. So those at the event can just Follow the user to discover\u00a0everything that&#8217;s going on at the event, and network with other Twitter users who are attending.<\/p>\n<p style=\"text-align: justify;\">Maybe you only want the bot to share only certain hashtagged Tweets from those Following you on Twitter, so you can Follow the account as a consumer or a provider. People will either Follow you because they want the latest news regarding the hashtagged subject, or because they want you to ReTweet their news.<\/p>\n<p style=\"text-align: justify;\">So as you can see, depending on how you are ReTweeting, and for what purpose, a ReTweet bot can be a great central hub of information and a network for open communication and discovery.<\/p>\n<p style=\"text-align: justify;\">Unfortunately, having shared with you now just a tiny portion of the possibilities of a ReTweet bot, there are still going to be some who are only looking to build a bot with the intention of spamming people. This tutorial then might seem a little like handing a child a loaded gun. But I&#8217;m going to trust here that you&#8217;ll be responsible enough to use this tutorial example to\u00a0<strong>learn<\/strong> and not to go spamming 100 ReTweets an hour. Twitter will ban you. And nobody likes a spammer.<\/p>\n<h2>Your First Unnecessarily Difficult ReTweet<\/h2>\n<p style=\"text-align: justify;\">So let&#8217;s test out this whole ReTweet thing by ReTweeting a single Tweet. Go find yourself something that you want to ReTweet and retrieve it&#8217;s status ID. (For the sake of saving a lot of people from getting mildly irritated by your Twitter bot testing, I do suggest you using your own Twitter accounts to test and play with. If you don&#8217;t already have another Twitter account, make one, or alternatively you can play with the corpse of\u00a0an abandoned account that hasn&#8217;t had any activity for years. But if it returns as an angry zombie, don&#8217;t blame me!<\/p>\n<p style=\"text-align: justify;\">You can find the status ID of a Tweet by clicking on the Tweet so it brings it up as its own page. (Twitter&#8217;s a little fiddly. You may want to click &#8220;Expand&#8221;, and then once the Tweet has expanded, click on &#8220;Details&#8221;. Once the page is loaded, there you can find the status ID in\u00a0the page&#8217;s URL in the address bar. It should look something like this:<\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ff6600;\"><strong>https:\/\/twitter.com\/YOUR_USERNAME\/status\/TWEET_STATUS_ID<\/strong><\/span><\/p>\n<p>Replace TWEET_ID\u00a0with that long number. That long number is the ID. (Your keys, tokens and secrets should still be kept as your actual keys, tokens and secrets throughout all tutorials obviously, as we covered in the <a title=\"How To Get Going With Twython\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/how-to-get-going-with-twython.html\" target=\"_blank\">tutorial last week<\/a>.)<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre style=\"color: #000000;\"><code>from twython import Twython\r\n\r\napp_key = \"YOUR_APP_KEY\"\r\napp_secret = \"YOUR_APP_SECRET\"\r\noauth_token = \"YOUR_OAUTH_TOKEN\"\r\noauth_token_secret = \"YOUR_OAUTH_TOKEN_SECRET\"\r\n\r\ntwitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)\r\n\r\n<span style=\"color: #ff6600;\">#ReTweeting by ID of the Tweet<\/span>\r\ntwitter.retweet(id = \"TWEET_ID\")<\/code><\/pre>\n<\/div>\n<p style=\"text-align: justify;\">Now check your Twitter profile! Has it ReTweeted successfully?<\/p>\n<p style=\"text-align: justify;\">Well, that&#8217;s all good and well, but it&#8217;s hardly going to be an automatic process if you&#8217;re going to be inserting the ID of each Tweet you want to ReTweet by hand each time. Thankfully, you won&#8217;t have to!<\/p>\n<h2 style=\"text-align: justify;\">Dissecting the Search Query<\/h2>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre style=\"color: #000000;\"><code><span style=\"color: #ff6600;\">#Import TwythonError now too!<\/span>\r\nfrom twython import Twython, TwythonError\r\n\r\napp_key = \"YOUR_APP_KEY\"\r\napp_secret = \"YOUR_APP_SECRET\"\r\noauth_token = \"YOUR_OAUTH_TOKEN\"\r\noauth_token_secret = \"YOUR_OAUTH_TOKEN_SECRET\"\r\n\r\ntwitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)\r\n\r\n<span style=\"color: #ff6600;\">#Setting Twitter's search results as a variable<\/span>\r\nsearch_results = twitter.search(q=\"SOMETHING\", count=10)\r\ntry:\r\n    for tweet in search_results[\"statuses\"]:\r\n        twitter.retweet(id = tweet[\"id_str\"])\r\nexcept TwythonError as e:\r\n    print e<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">For someone who&#8217;s completely new to Python, picking this up for the first time, that may just look like a strange block of code right now. So let&#8217;s break it down to the basics.<\/p>\n<p style=\"text-align: justify;\">Let&#8217;s start with <span style=\"color: #ff6600;\"><strong>search_results<\/strong><\/span>. We can read on Twitter&#8217;s REST API documentation that <span style=\"color: #ff6600;\"><strong>search<\/strong><\/span> takes a required parameter of <span style=\"color: #ff6600;\"><strong>q<\/strong><\/span> (for query). After all, to use the search results you do actually need to be searching for\u00a0<em>something<\/em>. In fact, you can see this for yourself when you do search for something on Twitter. When I perform a search for &#8220;southend&#8221; (the town in which we here at Silkstream are based &#8211; Southend, Essex), you can see in the URL that the search is taking a parameter of <span style=\"color: #ff6600;\"><strong>q=southend<\/strong><\/span>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1007\" alt=\"Southend Twitter Search\" src=\"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/southend-twitter-search.png\" width=\"443\" height=\"26\" \/><\/p>\n<p>So in our code, if we wanted to access the search results for &#8220;southend&#8221;, we would type:<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre style=\"color: #000000;\"><code>\r\nsearch_results = twitter.search(q=\"southend\", count=10)\r\n\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>And all that count is for is just to specify how many results we would like to return. In this case: <em>Twitter, I would like exactly <\/em><strong>ten<\/strong><em> search results back based on the query &#8220;southend&#8221; please!<\/em><\/p>\n<p>The count is an optional parameter, but a very useful one. Otherwise you might be biting off more than you can chew&#8230;<\/p>\n<p>Other optional search parameters include:<\/p>\n<ul>\n<li><strong>geocode<\/strong> &#8211; e.g. &#8220;longitude, latitude, radius&#8221;<\/li>\n<li><strong>lang<\/strong> &#8211; restricts Tweets to a certain language<\/li>\n<li><strong>locale\u00a0<\/strong>&#8211; specifies the query&#8217;s language<\/li>\n<li><strong>result_type<\/strong> &#8211; return mixed, recent or popular Tweets<\/li>\n<li><strong>until<\/strong> &#8211; returns Tweets generated before the given date<\/li>\n<li><strong>since_id<\/strong> &#8211; returns only Tweets more recent than the given one&#8217;s ID<\/li>\n<li><strong>max_id<\/strong> &#8211; returns only Tweets older than the given one&#8217;s ID<\/li>\n<li><strong>include_entities<\/strong> &#8211; the entities node will be disincluded when set to false<\/li>\n<\/ul>\n<p>As you can see, some are more useful than others depending on what it is you&#8217;re boiling things down to.<\/p>\n<h2>Automatically ReTweeting based on Search Query<\/h2>\n<p>So\u00a0what about:<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre><code>try:\r\n    for tweet in search_results[\"statuses\"]:\r\n        twitter.retweet(id = tweet[\"id_str\"])\r\nexcept TwythonError as e:\r\n    print e<\/code><\/pre>\n<\/div>\n<p style=\"text-align: justify;\">In the above bit of Python code here we are asking Twitter to try, for every Tweet&#8217;s status in our search results for &#8220;SOMETHING&#8221;, to ReTweet each Tweet that comes up for that search. Notice how instead of:<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre style=\"color: #000000;\"><code>twitter.retweet(id = \"TWEET_ID\")\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>we are now using:<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre style=\"color: #000000;\"><code>twitter.retweet(id = tweet[\"id_str\"])\r\n<\/code><\/pre>\n<\/div>\n<p style=\"text-align: justify;\">This is because, as you so cleverly pointed out earlier, we can&#8217;t sit there all day manually entering the IDs of every Tweet we want to ReTweet. It would be quicker to just use Twitter itself if we were to do that. It&#8217;s just plain silly.<\/p>\n<p style=\"text-align: justify;\">Instead we are telling Twitter to identify\u00a0the ID of each Tweet that pops up in our search results, and insert its ID there as a string. That&#8217;s the difference between\u00a0<span style=\"color: #ff6600;\"><strong>id<\/strong><\/span> and\u00a0<span style=\"color: #ff6600;\"><strong>id_str<\/strong><\/span>.\u00a0To set it as a non-string (or an integer) would mean that you are giving the ID a numerical value, which\u00a0we don&#8217;t want. So we want the number to be enclosed in quotation marks, indicating that it is a string. As we would if we were to be typing out the Tweet&#8217;s ID to be ReTweeted manually. Which we won&#8217;t do, because it&#8217;s just plain silly.<\/p>\n<h2 style=\"text-align: justify;\">And what about that\u00a0TwythonError?<\/h2>\n<p style=\"text-align: justify;\">What does TwythonError\u00a0do? This is just a generic &#8220;catch all&#8221; Error exception that will display the issue, should an error occur. For example, if it returns a HTTP status code of\u00a0403 in the console, the text will display as &#8220;Forbidden&#8221; and explain that, though the request was understood, it has been refused or access has not been allowed. You may find that this is due to you having hit a limit of some kind.<\/p>\n<h2 style=\"text-align: justify;\">Filtering search queries to ReTweet<\/h2>\n<p style=\"text-align: justify;\">Sometimes there are words that you will want to prevent from automatically ReTweeting, such as curse words, irrelevant words or words that express a certain sentiment. Or we have a multiple choice of words that we want Twitter to search for, such as a variation of spellings for a keyword and such.<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre><code><span style=\"color: #000000;\">from twython import Twython, TwythonError\r\n\r\napp_key = \"YOUR_APP_KEY\"\r\napp_secret = \"YOUR_APP_SECRET\"\r\noauth_token = \"YOUR_OAUTH_TOKEN\"\r\noauth_token_secret = \"YOUR_OAUTH_TOKEN_SECRET\"\r\n\r\n<\/span><span style=\"color: #ff6600;\">#Let's gather a list of words we DON'T want to RT<\/span><span style=\"color: #000000;\">\r\nnaughty_words = [\" -RT\", \"Boston\", \"football\", \"charlotte\", \"amos\"]\r\n<\/span><span style=\"color: #ff6600;\">#And a list of words we WOULD like to RT<\/span><span style=\"color: #000000;\">\r\ngood_words = [\"southend\", \"southendonsea\", \"southend on sea\"]\r\n<\/span><span style=\"color: #ff6600;\">#OR is Twitter's search operator to search for this OR that\r\n<\/span><span style=\"color: #ff6600;\">#So let's join everything in good_words with an OR!<\/span><span style=\"color: #000000;\">\r\nfilter = \" OR \".join(good_words)\r\n\r\n<\/span><span style=\"color: #ff6600;\"># The - is Twitter's search operator for negative keywords\r\n<\/span><span style=\"color: #000000;\"><span style=\"color: #ff6600;\"># So we want to prefix every negative keyword with a -<\/span>\r\nblacklist = \" -\".join(naughty_words)\r\n\r\n<span style=\"color: #ff6600;\">#And finally our list of keywords that we want to search for\r\n#This will search for any words in good_words minus any naughty_words<\/span>\r\nkeywords = filter + blacklist\r\n\r\ntwitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)\r\n\r\n<span style=\"color: #ff6600;\">#This time we want to set our q to search for our keywords<\/span>\r\nsearch_results = twitter.search(q=keywords, count=10)\r\ntry:\r\n    for tweet in search_results[\"statuses\"]:\r\n        try:\r\n            twitter.retweet(id = tweet[\"id_str\"])\r\n        except TwythonError as e:\r\n            print e\r\nexcept TwythonError as e:\r\n    print e<\/span><\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">So again, let&#8217;s take a closer look at everything new we&#8217;ve added to our Twitter bot.<\/p>\n<p style=\"text-align: justify;\">So we&#8217;ve made an example list of <span style=\"color: #ff6600;\"><strong>naughty_words<\/strong><span style=\"color: #333333;\">, and since for this example we want to be ReTweeting Tweets about Silkstream&#8217;s hometown of Southend in Essex, I&#8217;ve included negative keywords like &#8220;boston&#8221;, &#8220;charlotte&#8221; and &#8220;amos&#8221; as they tend to be popular keywords used in Tweets containing &#8220;Southend&#8221; but SouthEnd (or South End) in the United States rather than in Essex, UK.<\/span><\/span><\/p>\n<p style=\"text-align: justify;\">I&#8217;ve also added &#8220;football&#8221; just for this example (I don&#8217;t really care too much about football news myself&#8230;) and I&#8217;ve also added at the beginning &#8221; -RT&#8221;. I don&#8217;t want to be ReTweeting ReTweets so it&#8217;s important for me to add that. You may also notice that I&#8217;ve prefixed it with a &#8221; -&#8220;, which as we know is the negative keyword search operator on Twitter. This is because when we joined the <strong><span style=\"color: #ff6600;\">naughty_words<\/span><\/strong> for our blacklist, it does just that. It joins each item in that list. And since &#8221; -RT&#8221; is our first item, it doesn&#8217;t add a &#8221; -&#8221; to the beginning. So we&#8217;ve had to do that manually. Since it&#8217;s a one off and the program is just for us, it&#8217;s just easier to do it manually for now.<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre><code>filter = \" OR \".join(good_words)\r\nblacklist = \" -\".join(naughty_words)\r\nkeywords = filter + blacklist<\/code><\/pre>\n<\/div>\n<p style=\"text-align: justify;\">We&#8217;re using Twitter&#8217;s OR operator to join our <strong><span style=\"color: #ff6600;\">good_words<\/span><\/strong> so that Twitter knows that we&#8217;re searching for any Tweet that contains &#8220;southend OR southendonsea OR southend on sea&#8221;. Which is why our &#8221; OR &#8221; has spaces before and after the OR. So it doesn&#8217;t search for &#8220;southendORsouthendonseaORsouthend on sea&#8221;.<\/p>\n<p style=\"text-align: justify;\">Likewise, as we already covered, our <span style=\"color: #ff6600;\"><strong>blacklist<\/strong><span style=\"color: #333333;\"> joins every item in our <strong><span style=\"color: #ff6600;\">naughty_words<\/span><\/strong> by a &#8221; -&#8220;, with a space before the &#8220;-&#8221; but not after. So Twitter will search for &#8220;-RT -Boston -football -charlotte -amos&#8221;, and not &#8220;-RT-Boston-football-charlotte-amos&#8221;.<\/span><\/span><\/p>\n<p style=\"text-align: justify;\">And finally, our <strong><span style=\"color: #ff6600;\">keywords<\/span><\/strong>\u00a0list is just a concatenation of our <strong><span style=\"color: #ff6600;\">filter<\/span><\/strong> and our <strong><span style=\"color: #ff6600;\">blacklist<\/span><\/strong>\u00a0so if we set our search query to <strong><span style=\"color: #ff6600;\">keywords<\/span><\/strong>, Twitter will be searching for:<\/p>\n<p style=\"text-align: center;\"><strong><span style=\"color: #ff6600;\">southend OR southendonsea OR southend on sea\u00a0-RT -Boston -football -charlotte -amos<\/span><\/strong><\/p>\n<p style=\"text-align: justify;\">Awesome. So our Twitter ReTweet bot right now should look a little like this:<\/p>\n<div style=\"border: dashed #f79239; padding: 8px;\">\n<pre><code><span style=\"color: #000000;\">from twython import Twython, TwythonError\r\n\r\napp_key = \"YOUR_APP_KEY\"\r\napp_secret = \"YOUR_APP_SECRET\"\r\noauth_token = \"YOUR_OAUTH_TOKEN\"\r\noauth_token_secret = \"YOUR_OAUTH_TOKEN_SECRET\"\r\n<\/span><span style=\"color: #000000;\">\r\nnaughty_words = [\" -RT\", \"Boston\", \"football\", \"charlotte\", \"amos\"]<\/span><span style=\"color: #000000;\">\r\ngood_words = [\"southend\", \"southendonsea\", \"southend on sea\"]<\/span><span style=\"color: #000000;\">\r\nfilter = \" OR \".join(good_words)<\/span><span style=\"color: #000000;\">\r\nblacklist = \" -\".join(naughty_words)\r\nkeywords = filter + blacklist\r\n\r\ntwitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)\r\n\r\nsearch_results = twitter.search(q=keywords, count=10)\r\ntry:\r\n    for tweet in search_results[\"statuses\"]:\r\n        try:\r\n            twitter.retweet(id = tweet[\"id_str\"])\r\n        except TwythonError as e:\r\n            print e\r\nexcept TwythonError as e:\r\n    print e<\/span><\/code><\/pre>\n<\/div>\n<p style=\"text-align: center;\"><strong>Next week, we&#8217;ll be looking to tinker a little bit more with our Twitter ReTweet bot and\u00a0<em>really<\/em> see what this baby can do!<\/strong><\/p>\n<h3 style=\"text-align: center;\"><a title=\"How To Get Going with Twython\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/how-to-get-going-with-twython.html\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1009 alignleft\" alt=\"How To Get Going With Twython\" src=\"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/orange-arrow-left.png\" width=\"127\" height=\"120\" \/>The Noob&#8217;s Guide to Twython &#8211; Part 1:<\/a><\/h3>\n<p style=\"text-align: center;\"><a title=\"How To Get Going with Twython\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/how-to-get-going-with-twython.html\"><strong>How To Get Going With Twython<\/strong><\/a><\/p>\n<h3 style=\"text-align: center;\"><a title=\"Random Tweets with Twython\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/random-tweets-with-twython.html\">The Noob&#8217;s Guide to Twython &#8211; Part 3:<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1010 alignright\" alt=\"\" src=\"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/orange-arrow-right.png\" width=\"127\" height=\"120\" \/><\/a><\/h3>\n<p style=\"text-align: center;\"><a title=\"Random Tweets with Twython\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/random-tweets-with-twython.html\"><strong>Random Tweets with Twython<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\nLast week in this Noob&#8217;s Guide to Twython we covered setting up your Twython for the first time (installing Twython, authenticating with the Twitter <\/p>\n","protected":false},"author":7,"featured_media":1003,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,7],"tags":[],"class_list":["post-1000","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-online-marketing","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ReTweeting with your Twython Twitter Bot - Silkstream | Web Design Blog<\/title>\n<meta name=\"description\" content=\"The second part of our Noob&#039;s Guide To Twython, where we will be looking at creating your very own Twitter ReTweet Bot that filters the search query.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ReTweeting with your Twython Twitter Bot - Silkstream | Web Design Blog\" \/>\n<meta property=\"og:description\" content=\"The second part of our Noob&#039;s Guide To Twython, where we will be looking at creating your very own Twitter ReTweet Bot that filters the search query.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html\" \/>\n<meta property=\"og:site_name\" content=\"Silkstream\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/silkstream\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-13T12:27:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-05T14:56:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/twython-guide-thumb-2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"120\" \/>\n\t<meta property=\"og:image:height\" content=\"120\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ria\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@RiaLolwut\" \/>\n<meta name=\"twitter:site\" content=\"@silkstreamnet\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ria\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html\"},\"author\":{\"name\":\"Ria\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/#\\\/schema\\\/person\\\/1516b66b9d6da001d8052655282481b1\"},\"headline\":\"Noob&#8217;s Guide #2: ReTweeting with your Twython Twitter Bot\",\"datePublished\":\"2014-06-13T12:27:15+00:00\",\"dateModified\":\"2014-09-05T14:56:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html\"},\"wordCount\":1857,\"commentCount\":20,\"image\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/twython-guide-thumb-2.jpg\",\"articleSection\":[\"Online Marketing\",\"Tutorials\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html\",\"url\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html\",\"name\":\"ReTweeting with your Twython Twitter Bot - Silkstream | Web Design Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/twython-guide-thumb-2.jpg\",\"datePublished\":\"2014-06-13T12:27:15+00:00\",\"dateModified\":\"2014-09-05T14:56:52+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/#\\\/schema\\\/person\\\/1516b66b9d6da001d8052655282481b1\"},\"description\":\"The second part of our Noob's Guide To Twython, where we will be looking at creating your very own Twitter ReTweet Bot that filters the search query.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#primaryimage\",\"url\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/twython-guide-thumb-2.jpg\",\"contentUrl\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/twython-guide-thumb-2.jpg\",\"width\":120,\"height\":120},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/2014\\\/06\\\/retweeting-with-your-twython-twitter-bot.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.silkstream.net\\\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Noob&#8217;s Guide #2: ReTweeting with your Twython Twitter Bot\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/\",\"name\":\"Silkstream\",\"description\":\"Here you&#039;ll find the latest blogs, white papers and case studies from Silkstream experts.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.silkstream.net\\\/blog\\\/#\\\/schema\\\/person\\\/1516b66b9d6da001d8052655282481b1\",\"name\":\"Ria\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dad9acd650d88d7fd9c7e2b77f38d25ec2c921eb7efb622d785820719d8a75df?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dad9acd650d88d7fd9c7e2b77f38d25ec2c921eb7efb622d785820719d8a75df?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dad9acd650d88d7fd9c7e2b77f38d25ec2c921eb7efb622d785820719d8a75df?s=96&d=mm&r=g\",\"caption\":\"Ria\"},\"description\":\"SEO &amp; Internet Marketing addict, and aspiring crazy cat lady.\",\"sameAs\":[\"http:\\\/\\\/www.silkstream.net\",\"https:\\\/\\\/x.com\\\/RiaLolwut\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ReTweeting with your Twython Twitter Bot - Silkstream | Web Design Blog","description":"The second part of our Noob's Guide To Twython, where we will be looking at creating your very own Twitter ReTweet Bot that filters the search query.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html","og_locale":"en_GB","og_type":"article","og_title":"ReTweeting with your Twython Twitter Bot - Silkstream | Web Design Blog","og_description":"The second part of our Noob's Guide To Twython, where we will be looking at creating your very own Twitter ReTweet Bot that filters the search query.","og_url":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html","og_site_name":"Silkstream","article_publisher":"https:\/\/www.facebook.com\/silkstream","article_published_time":"2014-06-13T12:27:15+00:00","article_modified_time":"2014-09-05T14:56:52+00:00","og_image":[{"width":120,"height":120,"url":"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/twython-guide-thumb-2.jpg","type":"image\/jpeg"}],"author":"Ria","twitter_card":"summary_large_image","twitter_creator":"@RiaLolwut","twitter_site":"@silkstreamnet","twitter_misc":{"Written by":"Ria","Estimated reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#article","isPartOf":{"@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html"},"author":{"name":"Ria","@id":"https:\/\/www.silkstream.net\/blog\/#\/schema\/person\/1516b66b9d6da001d8052655282481b1"},"headline":"Noob&#8217;s Guide #2: ReTweeting with your Twython Twitter Bot","datePublished":"2014-06-13T12:27:15+00:00","dateModified":"2014-09-05T14:56:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html"},"wordCount":1857,"commentCount":20,"image":{"@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#primaryimage"},"thumbnailUrl":"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/twython-guide-thumb-2.jpg","articleSection":["Online Marketing","Tutorials"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html","url":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html","name":"ReTweeting with your Twython Twitter Bot - Silkstream | Web Design Blog","isPartOf":{"@id":"https:\/\/www.silkstream.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#primaryimage"},"image":{"@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#primaryimage"},"thumbnailUrl":"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/twython-guide-thumb-2.jpg","datePublished":"2014-06-13T12:27:15+00:00","dateModified":"2014-09-05T14:56:52+00:00","author":{"@id":"https:\/\/www.silkstream.net\/blog\/#\/schema\/person\/1516b66b9d6da001d8052655282481b1"},"description":"The second part of our Noob's Guide To Twython, where we will be looking at creating your very own Twitter ReTweet Bot that filters the search query.","breadcrumb":{"@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#primaryimage","url":"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/twython-guide-thumb-2.jpg","contentUrl":"https:\/\/www.silkstream.net\/blog\/wp-content\/uploads\/2014\/06\/twython-guide-thumb-2.jpg","width":120,"height":120},{"@type":"BreadcrumbList","@id":"https:\/\/www.silkstream.net\/blog\/2014\/06\/retweeting-with-your-twython-twitter-bot.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silkstream.net\/blog"},{"@type":"ListItem","position":2,"name":"Noob&#8217;s Guide #2: ReTweeting with your Twython Twitter Bot"}]},{"@type":"WebSite","@id":"https:\/\/www.silkstream.net\/blog\/#website","url":"https:\/\/www.silkstream.net\/blog\/","name":"Silkstream","description":"Here you&#039;ll find the latest blogs, white papers and case studies from Silkstream experts.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.silkstream.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.silkstream.net\/blog\/#\/schema\/person\/1516b66b9d6da001d8052655282481b1","name":"Ria","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/dad9acd650d88d7fd9c7e2b77f38d25ec2c921eb7efb622d785820719d8a75df?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dad9acd650d88d7fd9c7e2b77f38d25ec2c921eb7efb622d785820719d8a75df?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dad9acd650d88d7fd9c7e2b77f38d25ec2c921eb7efb622d785820719d8a75df?s=96&d=mm&r=g","caption":"Ria"},"description":"SEO &amp; Internet Marketing addict, and aspiring crazy cat lady.","sameAs":["http:\/\/www.silkstream.net","https:\/\/x.com\/RiaLolwut"]}]}},"_links":{"self":[{"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/posts\/1000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/comments?post=1000"}],"version-history":[{"count":10,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/posts\/1000\/revisions"}],"predecessor-version":[{"id":1561,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/posts\/1000\/revisions\/1561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/media\/1003"}],"wp:attachment":[{"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/media?parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/categories?post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silkstream.net\/blog\/wp-json\/wp\/v2\/tags?post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}