{"id":1070,"date":"2014-06-04T02:05:56","date_gmt":"2014-06-04T02:05:56","guid":{"rendered":"http:\/\/kraftek.com\/blog\/?p=1070"},"modified":"2014-06-04T02:07:32","modified_gmt":"2014-06-04T02:07:32","slug":"post-a-tweet-to-my-twitter-using-pythons-tweepy","status":"publish","type":"post","link":"\/blog\/index.php\/post-a-tweet-to-my-twitter-using-pythons-tweepy\/","title":{"rendered":"post a tweet to my twitter, using python&#8217;s tweepy"},"content":{"rendered":"<p>I automated a twitter update from a random fortune quote, using python and the tweepy library.<br \/>\nFirst i installed tweepy<\/p>\n<pre>\r\n# pip install tweepy\r\n<\/pre>\n<p>Then, created \/opt\/bin\/tweepy<\/p>\n<pre>\r\n#!\/opt\/bin\/python\r\nimport tweepy, sys, commands\r\nquote=commands.getoutput(\"\/opt\/bin\/fortune\")\r\nconsumer_key, consumer_secret, access_token, access_token_secret = \"xxxxxx\", \"xxxx\", \"xxx\", \"xxx\"\r\nauth = tweepy.OAuthHandler(consumer_key, consumer_secret)\r\nauth.set_access_token(access_token, access_token_secret)\r\napi = tweepy.API(auth)\r\n#print \"Successfully logged in as \" + api.me().name + \".\"\r\napi.update_status(quote)\r\n<\/pre>\n<p>And.. that&#8217;s it!. As easy as 1..2..<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I automated a twitter update from a random fortune quote, using python and the tweepy library. First i installed tweepy # pip install tweepy Then, created \/opt\/bin\/tweepy #!\/opt\/bin\/python import tweepy, sys, commands quote=commands.getoutput(&#8220;\/opt\/bin\/fortune&#8221;) consumer_key, consumer_secret, access_token, access_token_secret = &#8220;xxxxxx&#8221;, &#8220;xxxx&#8221;, &#8220;xxx&#8221;, &#8220;xxx&#8221; auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) #print &#8220;Successfully logged in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1070","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1070"}],"version-history":[{"count":2,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1072,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1070\/revisions\/1072"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}