Skip to content

Instantly share code, notes, and snippets.

@Songmu
Created December 16, 2010 00:31
Show Gist options
  • Save Songmu/742838 to your computer and use it in GitHub Desktop.
Save Songmu/742838 to your computer and use it in GitHub Desktop.
EmEditor macro to post twitter msgs
#language="PerlScript"
our $Window;
use strict;
use warnings;
use utf8;
use YAML::Syck;
use Encode;
use Net::Twitter;
our $VERSION = 0.01;
use Win32::OLE;
Win32::OLE->Option(CP=>Win32::OLE::CP_UTF8);
my $document = $Window->document;
my $message = decode_utf8 $document->selection->Text;
$message =~ s/\s/ /g;
exit unless $message;
exit unless $Window->confirm('post?');
my $config_file = 'C:\myCom\conf\twitter.conf';
my $config = YAML::Syck::LoadFile($config_file) or die $!;
my $twit = Net::Twitter->new(
traits => [qw/API::REST OAuth WrapError/],
consumer_key => $config->{consumer_key},
consumer_secret => $config->{consumer_secret},
ssl => 1,
);
$twit->access_token ($config->{access_token});
$twit->access_token_secret($config->{access_token_secret});
$twit->update( $message ) or die;
$document->Write("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment