<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2009-05-01:152029</id>
  <title>jodi</title>
  <subtitle>jodi</subtitle>
  <author>
    <name>jodi</name>
  </author>
  <link rel="alternate" type="text/html" href="https://jodi.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://jodi.dreamwidth.org/data/atom"/>
  <updated>2011-03-02T10:41:34Z</updated>
  <dw:journal username="jodi" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2009-05-01:152029:4786</id>
    <link rel="alternate" type="text/html" href="https://jodi.dreamwidth.org/4786.html"/>
    <link rel="self" type="text/xml" href="https://jodi.dreamwidth.org/data/atom/?itemid=4786"/>
    <title>Twitter bot</title>
    <published>2011-03-02T10:29:46Z</published>
    <updated>2011-03-02T10:41:34Z</updated>
    <category term="twitter"/>
    <category term="python"/>
    <category term="bot"/>
    <dw:security>public</dw:security>
    <dw:reply-count>8</dw:reply-count>
    <content type="html">I decided to start learning Python by creating a Twitter bot. I have an online diary, that I have been keeping for over a decade now, and I decided that I would output lines from it as tweets, so that I could keep in touch with my younger self. If you want to see it in action: &lt;a href="http://www.twitter.com/echochild"&gt;Echochild&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___1" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://jodi.dreamwidth.org/4786.html#cutid1"&gt;Things I found odd to start with in Python&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___1" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;There are quite a few Python to Twitter packages, but in the end, I decided upon &lt;a href="https://github.com/joshthecoder/tweepy"&gt;Tweepy&lt;/a&gt;.&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___2" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://jodi.dreamwidth.org/4786.html#cutid2"&gt;Installing Tweepy&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___2" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I formatted the diary entries, using Vi, so that there is just one sentence per line.&lt;br /&gt;&lt;br /&gt;I got the appropriate authorisation tokens from Twitter: consumer token, consumer secret, etc.&lt;br /&gt;&lt;br /&gt;Due to access restrictions, I am unable to run cron jobs or leave things running in the background, so concluded that being able to tweet just by going to a web page would do. Not quite automatic, but still, will do for now.&lt;br /&gt;&lt;br /&gt;I then created a CGI script in the joshthecoder-tweepy-fcaff74 directory.&lt;span class="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___3" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://jodi.dreamwidth.org/4786.html#cutid3"&gt;CGI script&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___3" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The next thing to do is make it actually reply to people!&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=jodi&amp;ditemid=4786" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
