randomfox: (Default)
[personal profile] randomfox
Adocu is a nanoblogging service. It is similar to Twitter, except that it limits your status update to one word. This script posts a status to Adocu. See the embedded POD at the end of the script for details on Adocu login configuration.


#!perl
# Client for Adocu.
# This script posts a one-word status to Adocu.

use strict;
use LWP::UserAgent; 
use MIME::Base64;
use Config::Auto;

my $config_fname = "adocu.conf";

# Get information from config file.
sub get_config {
    my $config = Config::Auto::parse($config_fname, format=>'equal');

    (defined $config->{login}) or die "Please define login in $config_fname\n";
    ($config->{login}, $config->{proxy}, $config->{proxylogin});
}

# Post a status to Adocu.
sub post_adocu {
    my ($login, $proxy, $proxylogin, $status) = @_;

    my $ua = new LWP::UserAgent;
    $ua->cookie_jar({});

    defined $proxy and $ua->proxy('http', "http://$proxy");

    $login =~ /:/ and $login = encode_base64($login);
    $ua->default_header('Authorization' => "Basic $login");

    if (defined $proxylogin) {
	$proxylogin =~ /:/ and $proxylogin = encode_base64($proxylogin);
	$ua->default_header('Proxy-Authorization' => "Basic $proxylogin");
    }

    # Post status to Adocu.
    my $response = $ua->post("http://adocu.com/api/status.xml", 
	{ 'msg'=>$status });
    $response->is_success or die $response->status_line."\n";

    print "Response from Adocu: ", $response->content, "\n";
}

my ($login, $proxy, $proxylogin) = get_config();

@ARGV >= 1 or die "Usage: $0 status\n";
my $status = shift;

post_adocu($login, $proxy, $proxylogin, $status);

__END__

=head1 NAME

Adocu.pl - Post a status to Adocu.

=head1 SYNOPSIS

adocu.pl I<status>

=head1 DESCRIPTION

Adocu is a nanoblogging service at L<http://adocu.com>. It differs from microblogging services in that Adocu limits you to one word when posting your status. This script posts a one-word status to Adocu.

Before using this script, you need to set your Adocu login information in C<adocu.conf>. If you're using a HTTP proxy, you can set proxy and proxy login (if necessary) information in that file too.

C<adocu.conf> may be placed in any location accepted by Config::Auto. See L<Config::Auto> for more information.

The format of adocu.conf is as follows:

    login = user:password
    proxy = proxyserver:proxyport
    proxylogin = proxyuser:proxypassword

If desired, the C<user:password> and C<proxyuser:proxypassword> strings may be Base64 encoded.

=head1 AUTHOR

Po Shan Cheah (morton@mortonfox.com) L<http://www.mortonfox.com>


=cut


Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 23rd, 2017 10:48 am
Powered by Dreamwidth Studios