-
Notifications
You must be signed in to change notification settings - Fork 2
/
potlatchtweet.cgi
81 lines (68 loc) · 1.77 KB
/
potlatchtweet.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
use strict;
use Net::Twitter::Lite;
use CGI;
use URI;
my $query = CGI->new;
my $res = URI->new;
my $success = 0;
my $errcode = 0;
my $errmsg = '';
my $errerr = '';
my $submitted = 0;
if ($query->param('tweet') and
defined ($query->param('lat')) and
defined ($query->param('long')) and
$query->param('twitter_id') and
$query->param('twitter_pwd')) {
$submitted = 1;
my $app = 'Potlatch';
my $ver = $query->param('clientver');
my $ua = $ver ? "$app/$ver" : $app;
my $twat = Net::Twitter::Lite->new(
traits => ['API::REST'],
username => $query->param('twitter_id'),
password => $query->param('twitter_pwd'),
useragent => $ua,
clientname => $app,
($query->param('clientver')
? (clientver => $ver)
: ()),
clienturl => 'http://openstreetmap.org/edit',
# identi.ca or twitter?
($query->param('identica')
? (identica => 1)
: ()),
# identica takes this as-is, twitter says "from web" because
# it isn't registering source parameters anymore, we'd have to
# use OAuth to play nice with it.
source => $app,
);
eval {
$twat->update({
status => $query->param('tweet'),
lat => $query->param('lat'),
long => $query->param('long')
});
};
if (my $err = $@) {
$errcode = $err->code;
$errmsg = $err->message;
$errerr = $err->error;
} else {
$success = 1;
}
}
$res->query_form(
success => $success,
errcode => $errcode,
errmsg => $errmsg,
errerr => $errerr,
submit => $submitted,
);
my $q = $res->as_string;
$q =~ s/^\?//;
print <<EOF;
Content-Type: application/x-www-form-urlencoded
&$q&
EOF