source: subversion/applications/editors/potlatch/potlatchtweet.cgi @ 18699

Last change on this file since 18699 was 18699, checked in by avar, 10 years ago

Change the potlatchtweet script to use Net::Twitter and add identi.ca
support. The script is still backwards-compatable.

File size: 1.4 KB
Line 
1#!/usr/bin/perl
2use strict;
3use Net::Twitter;
4use CGI;
5
6my $query = CGI->new;
7my $success = 0;
8my $errcode = 0;
9my $params = 0;
10
11if ($query->param('tweet') and
12    $query->param('lat') and
13    $query->param('long') and
14    $query->param('twitter_id') and
15    $query->param('twitter_pwd') and
16    $query->param('clientver')) {
17    $params = 1;
18    my $app = 'Potlatch';
19    my $ver = $query->param('clientver');
20    my $ua = "$app/$ver";
21
22    my $twat = Net::Twitter->new(
23        traits => ['API::REST'],
24        username => $query->param('twitter_id'),
25        password => $query->param('twitter_pwd'),
26        useragent  => $ua,
27        clientname => $app,
28        clientver  => $ver,
29        clienturl  => 'http://openstreetap.org/edit',
30
31        # identi.ca or twitter?
32        ($query->param('identica')
33         ? (identica => 1)
34         : ()),
35
36        # identica takes this as-is, twitter says "from web" because
37        # it isn't registering source paramaters anymore, we'd have to
38        # use OAuth to play nice with it.
39        source => $app,
40    );
41
42    eval {
43        $twat->update({
44            status => $query->param('tweet'),
45            lat => $query->param('lat'),
46            long => $query->param('long')
47        });
48    };
49    if (my $err = $@) {
50        $errcode = $err->code;
51    } else {
52        $success = 1;
53    }
54}
55        print <<EOF;
56Content-Type: application/x-www-form-urlencoded
57
58&success=$success&errcode=$errcode&params=$params&
59EOF
60
Note: See TracBrowser for help on using the repository browser.