Diff: CommandLineTwitter

Differences between version 3 and previous revision of CommandLineTwitter.

Other diffs: Previous Major Revision, Previous Author

Newer page: version 3 Last edited on March 1, 2012 12:17 pm by PhilHollenback Revert
Older page: version 2 Last edited on February 29, 2012 11:15 pm by PhilHollenback Revert
@@ -81,34 +81,4 @@
  
 I also really want to see if I can write an extension to use the bit.ly api to shorten urls instead of using is.gd. 
  
 Another fun idea: an extension that creates github gists from tweets or something along those lines. 
-  
-  
------  
-  
-<?plugin RawHtml  
-<script>  
-var idcomments_acct = '011e5665a1128cdbe79c8077f0f04353';  
-var idcomments_post_id;  
-var idcomments_post_url;  
-</script>  
-<span id="IDCommentsPostTitle" style="display:none"></span>  
-<script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>  
-?>  
-  
------  
-  
-<?plugin RawHtml  
-<center>  
-<script type="text/javascript"><!--  
-google_ad_client = "pub-5011581245921339";  
-google_ad_width = 728;  
-google_ad_height = 90;  
-google_ad_format = "728x90_as";  
-google_ad_channel ="";  
-//--></script>  
-<script type="text/javascript"  
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  
-</script>  
-</center>  
-?>  

version 3

Command Line Twitter

My notes on setting up the command line twitter client ttytter on my Mac.

Install the ttytter readline module with

$ sudo cpan Term::ReadLine::TTYtter

This gives you a readline which counts total characters per line (VERY IMPORTANT).

my ~/.ttytterrc:

ansi=1
verify=1
track='#sysadmin'
readline=1
vcheck=1
mentions=1
urlopen=open %U
avatar=open %U
backload=40
simplestart=1
ssl=1
newline=1
exts=/Users/barney/.ttytter/instapaper.pl
[email protected]
extpref_instapaper_password=badpass
mkdir ~/.ttytter

Put instapaper.pl in the ~/.ttytter directory:

#instapaper.pl Extension code by @augmentedfourth http://www.twitter.com/augmentedfourth
# Add a command (/later) to add tweet to Instapaper
#Released under the WTFPL: http://en.wikipedia.org/wiki/WTFPL

$addaction = sub {
   my $command = shift;

   if ($command =~ m#^/later (.+)#) {
      my $tweet_id=$1;
      my $tweet = &get_tweet($tweet_id);
      if (!$tweet->{'id_str'}) {
         print $stdout "-- sorry, no such tweet (yet?).\n";
         return 1;
      }
      #modified to use .ttytterrc by @stormdragon2976 http://www.twitter.com/stormdragon2976
      if ((!defined($extpref_instapaper_username)) || (!defined($extpref_instapaper_password)))
      {
        print $streamout ("Instapaper information not found. ");
        print $streamout ("Please add extpref_instapaper_username and extpref_instapaper_password ");
        print $streamout ("to your .ttytterrc.\n");
        return 1;
      }
      my $ip_user = $extpref_instapaper_username;
      my $ip_pass = $extpref_instapaper_password;
      my $add_url="twitter.com/$tweet->{'user'}->{'screen_name'}/statuses/$tweet->{'id'}";
      my $ip_url="https://www.instapaper.com/api/add?url=" . $add_url . "&username=" .
        $ip_user . "&password=" . $ip_pass . "&auto-title=1";
      my $content = `curl -s \"$ip_url\"`;
      if ($content =~ /201/){
         print "Added to Instapaper!\n";
      }else{
         print "Something went wrong, not added. Error code: ";
         print "$content\n";
      }
      return 1;
   }

   return 0;
};

To Do

I really want to rewrite the instapaper extension as an exercise to make it all perl (and try using LWP::Simple). It would also be nice if the extension printed a 'trying to add to instapaper ... success!' sort of message instead of just waiting until success or failure to complete (although the asynchronous nature of ttytter may make that difficult).

I also really want to see if I can write an extension to use the bit.ly api to shorten urls instead of using is.gd.

Another fun idea: an extension that creates github gists from tweets or something along those lines.



Our Founder
ToolboxClick to hide/show
RecentChanges Click to hide/show