Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use Encode ();
- use AnyEvent::Twitter;
- use AnyEvent::ReverseHTTP 0.04;
- use Config::Pit qw/pit_get/;
- use HTTP::Request::AsCGI ();
- use CGI::Simple ();
- my $config = pit_get(
- "b2t",
- require => {
- "username" => "your username",
- "password" => "your password",
- "label" => "your reverse http label",
- }
- );
- my $twitty = AnyEvent::Twitter->new(
- username => $config->{username},
- password => $config->{password},
- );
- my $guard = reverse_http $config->{label}, sub {
- my $req = shift;
- my $c = HTTP::Request::AsCGI->new($req)->setup;
- my $q = CGI::Simple->new;
- my $msg = '[B]'
- . join(
- ' ',
- (
- map { Encode::decode_utf8($_) } $q->param('title'), $q->param('url')
- )
- );
- if ($msg =~ /\S/) {
- warn "POSTING $msg";
- $twitty->update_status($msg, sub {
- my ($twitty, $status, $js_status, $error) = @_;
- if (defined $error) {
- warn "ERROR: $error";
- } else {
- warn "posted";
- }
- });
- }
- return "OK";
- };
- AnyEvent->condvar->recv;
- # Copyright (C) 2009 tokuhirom
- # licensed by artistic license.
Add Comment
Please, Sign In to add comment