-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpubsubhubbub-publish
executable file
·48 lines (38 loc) · 1.1 KB
/
pubsubhubbub-publish
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
#!/usr/bin/perl
# -*-perl-*-
use strict;
use lib 'lib';
use Net::PubSubHubbub::Publisher;
use Getopt::Long;
use LWP::Simple ();
sub usage {
my $err = shift;
if ($err) {
warn "ERROR: $err\n\n";
}
print STDERR <<END;
Usage: pubsubhubbub-publish [OPTS] <topic_url> [<topic_url2> ...]
Pings the hub, notifying the hub that the provided 'topic_url' has
been updated.
Options:
--hub=<hub_publish_endpoint> Which hub endpoint to ping. Defaults
to the open, reference hub, but you need to use whatever hub
that your Topic URL references.
END
exit(1);
}
my $hub = "http://pubsubhubbub.appspot.com/";
GetOptions("hub=s" => \$hub)
or usage();
my @topic_urls = @ARGV or usage("topic_url required.");
foreach my $url (@topic_urls) {
usage("Bogus topic URL: $url")
unless $url =~ m!^https?://\S+$!;
}
usage("No hub provided.")
unless $hub && $hub =~ m!^https?://\S+$!;
my $publisher = Net::PubSubHubbub::Publisher->new(hub => $hub);
unless ($publisher->publish_update(@topic_urls)) {
warn "Error pinging hub: " . $publisher->last_response->status_line;
exit(1);
}