![]() |
SkyAlert.org >> View Streams | View Events | View Alerts |
Events can be manually validated and authored through the web form interface, but this is not difficult to automate, as described below. It can be done in most languages through a URL API, or via the curl and wget utilities. Below we sketch some code in specific languages. in the codes below, the strings that begin 'mySkyalert' should be replaced with the correct values.
The Python code is part of a suite of client programs that can be used in conjunction with the Skyalert Client Kit.
# publishes an event to a Skyalert, needs username, password, streamname
# as well as the VOEvent itself
import urllib
dict = {}
# the server that will handle the submit request
publishingEndpoint = "https://betelgeuse.ligo.caltech.edu:8000/submit/"
# choose 'validate' for validation and 'publish' for publishing
dict['actionType'] = 'publish'
#dict['actionType'] = 'validate'
# Skyalert username and password
dict['username'] = 'mySkyalertUsername'
dict['password'] = 'mySkyalertPassword'
# open a file for the XML
dict['xmlText'] = open('sample.xml').read()
# The skyalert publisher expects streamName to match its own short name
# doRules controls if alerts be run once the event is ingested?
# Wrap up the ad hoc parameters in actionDetail
dict['actionDetail'] = '{"streamName":"CRTS", "doRules":0}'
# Now send it off and print the result
params = urllib.urlencode(dict)
f = urllib.urlopen(publishingEndpoint, params)
result = f.read()
print result
use strict;
use Carp;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
# read in the file
open my $FILE, '<',"sample.xml" or croak "can't read";
local $/ = undef;
my $xml = <$FILE>;
# url of the submit resource
my $url = 'http://skyalert.org/submit/';
my $req = POST $url, [
actionType => 'validate',
# actionType => 'publish',
xmlText => $xml,
# uncomment the following for authoring events
actionDetail => '{"streamName":"mySkyalertStream", "doRules":1}',
username => 'mySkyalertUsername',
password => 'mySkyalertPassword',
];
print $ua->request($req)->as_string;