import urllib.request
import urllib.error
import urllib.parse
import xml.dom.minidom
from xml.dom.minidom import parse, parseString

theurl = "http://www.agendize.com/api/1.0/action?media=sms&key=3ac024abf8c72460764b965199f81808f4cb08&id=142514&phone=+33611111111"

# Build password manager by setting th parameter "realm" as default
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
# Add a passwword to our password manager
password_mgr.add_password(None, theurl, "myusername", "mypassword")
# Create our HTML request manager by activing authentication
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
# Build the opener using our request manager
opener = urllib.request.build_opener(handler)
# Install the opener to be efficient
urllib.request.install_opener(opener)
# Make the connection 
handle = urllib.request.urlopen(theurl)
# Convert in string
chaineResultat = bytes.decode(handle.read())

# Retrieve AgendiZe response code obtained by searching in the parsed xml content
dom = parseString(chaineResultat)
element = dom.getElementsByTagName("result")[0]
print(element.childNodes[0].data)
    