Ignore:
Timestamp:
May 21, 2009, 4:51:34 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
8496cc2
Parents:
d658c29
git-author:
Kevin Riggle <kevinr@free-dissociation.com> (05/19/09 22:54:48)
git-committer:
Nelson Elhage <nelhage@mit.edu> (05/21/09 16:51:34)
Message:
Preliminary support for other Twitter-compatible microblogging services, eg. identi.ca.

Adds an optional 'service' parameter to the configuration file, which points to the API
root URL (defaults to Twitter's).  Also adds optional 'apihost' and 'apirealm' parameters
for the domain name and port of the site to connect to, and the name of the API realm,
respectively (default to Twitters'; if service is not Twitter, attempt to guess sane
defaults).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter.pm

    rd658c29 ra0385ad3  
    9494}
    9595
    96 $twitter  = Net::Twitter->new(username   => $cfg->{user} || $user,
    97                               password   => $cfg->{password},
    98                               source => 'barnowl');
     96my $twitter_args = { username   => $cfg->{user} || $user,
     97                     password   => $cfg->{password},
     98                     source     => 'barnowl',
     99                   };
     100if (defined $cfg->{service}) {
     101    my $service = $cfg->{service};
     102    $twitter_args->{apiurl} = $service;
     103    my $apihost = $service;
     104    $apihost =~ s/^\s*http:\/\///;
     105    $apihost =~ s/\/.*$//;
     106    $apihost .= ':80' unless $apihost =~ /:\d+$/;
     107    $twitter_args->{apihost} = $cfg->{apihost} || $apihost;
     108    my $apirealm = "Laconica API";
     109    $twitter_args->{apirealm} = $cfg->{apirealm} || $apirealm;
     110}
     111
     112$twitter  = Net::Twitter->new(%$twitter_args);
    99113
    100114if(!defined($twitter->verify_credentials())) {
     
    189203                location  => decode_entities($tweet->{user}{location}||""),
    190204                body      => decode_entities($tweet->{text}),
    191                 status_id => $tweet->{id}
     205                status_id => $tweet->{id},
     206                service   => $cfg->{service},
    192207               );
    193208            BarnOwl::queue_message($msg);
     
    221236                location  => decode_entities($tweet->{sender}{location}||""),
    222237                body      => decode_entities($tweet->{text}),
    223                 isprivate => 'true'
     238                isprivate => 'true',
     239                service   => $cfg->{service},
    224240               );
    225241            BarnOwl::queue_message($msg);
     
    264280                direction => 'out',
    265281                body      => $msg,
    266                 isprivate => 'true'
     282                isprivate => 'true',
     283                service   => $cfg->{service},
    267284               );
    268285            BarnOwl::queue_message($tweet);
Note: See TracChangeset for help on using the changeset viewer.