This covers the process of posting an error from your website into Arecibo. There main method of sending an error to Arecibo is by a HTTP post. It’s easy to add in your own and hopefully more will be made open source.
The URL for version 1 of the API is:
When the next major release of Arecibo API happens, we will increment the URL to /v/2/, leaving the /v/1/ active. This will allow clients to upgrade as needed.
The method for sending an error is simple, a HTTP POST to the above URL containing the variables set out in the documentation.
In this example we’ll use the public test site:
Sending a HTTP POST in Python is easy using the urllib module. The most minimal request that can be sent just contains the API key, so let’s send that as a first example:
>>> import urllib
>>> data = {"account":"w3;5qwy45qshtqu46tdtgheq47s.ert6ew45e4i2w65"}
>>> encoded = urllib.urlencode(data)
>>> urllib.urlopen("http://test-areciboapp.appspot.com/v/1/", encoded).read()
'Error recorded'
If the request is successful, a HTTP status of 200 will be returned.
The only thing you can really do wrong with this is get the API key wrong, Arecibo will do its best to record the error no matter what the error. If you’ve got some things in the POST that are wrong besides the API key, then Arecibo will simply log them on error. Sending a false API key will give you:
>>> data = {"account":"wrongaccountnumber"}
>>> encoded = urllib.urlencode(data)
>>> urllib.urlopen("http://test-areciboapp.appspot.com/v/1/", encoded).read()
'Problem recording the error: Account wrongaccountnumber does not exist.'
The request will also return a HTTP status of 500.
Once you’ve established how to make your error post, you can proceed to add in more variables. Here we are sending an error including the priority, status and some extra information in the msg:
>>> data = {"account":"w3;5qwy45qshtqu46tdtgheq47s.ert6ew45e4i2w65", "status": 403, "priority": 1,
... "msg": "Someone tried to access /secure without the appropriate authorization"}
>>> encoded = urllib.urlencode(data)
>>> urllib.urlopen("http://test-areciboapp.appspot.com/v/1/", encoded).read()
'Error recorded'
For more detailed and full examples on how to do a such a POST, please see the existing sample clients Python, Ruby or JavaScript libraries. For example the Python library does: UTF-8 encoding, checks for required variables and sets time outs to prevent leaving sockets open.