Python sample
Download the last 25 messages in ERROR
This code snipet requires Python 2.6 or newer. No extra modules are required
import json
import urllib2
base_url = "https://www.babelway.net/SelfService3/rest/v2/";
my_hub = 0 #You can find this on the My Account page
user = "" #the username you use to connect to Babelway
pwd = "" #the password you use to connect to Babelway
request = "%shub-%s/messages.json" %(base_url, my_hub)
# Create a pwd manager that handles any realm (default realm)
pwd_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
# Create the authentication handler, add the login/pwd to it
auth_handler = urllib2.HTTPBasicAuthHandler(pwd_manager)
auth_handler.add_password(None, request, user, pwd)
# Build the URL Opener
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
# Read and parse the JSON response
try:
f = urllib2.urlopen(request)
print json.load(f)
except urllib2.HTTPError as e:
print e