22
edits
Changes
+getting started on code
=== Authorize the App on your Bot's Account ===
While still logged in under the bot's account, navigate to the app's page and generate your access token:
* '''<tt>access_token_secret</tt>'''
== Getting started on the code ==
Each Twitter API library is going to have its own way to get initialized and set up. Usually it's going to start with creating an object to represent your connection to Twitter and feeding it ALL THE KEYS.
my $twitter = Net::Twitter->new(
traits => [qw/API::REST OAuth/],
consumer_key => $conf{'consumer_key'},
consumer_secret => $conf{'consumer_secret'},
access_token => $conf{'access_token'},
access_token_secret => $conf{'access_token_secret'},
);
...and then you'll be able to use the library methods to do the things that you might want to do.
== Rules of the Road ==
=== Tweet updates from elsewhere ===
twitter = TwitterConnection.new()
at (interval) { msg == General things you may want to do ==fetch_external_resource; msg.truncate_to_140_chars; twitter->update(msg) }
=== Check for @-messages and reply ===
twitter =TwitterConnection.new() mentions =twitter->mentions( since_id = Tweet updates from elsewhere > last_mention ) at (interval) { foreach mention in mentions { mention.parse mention.reply last_mention =mention.id } } sub reply(mention) { msg =fetch_external_resource() msg = '@' + mention.sending_user->screen_name + ' ' + msg msg.truncate_to_140_chars twitter->update(msg, in_reply_to => mention) }