Monday, November 08, 2010 at 12:01 AM.


on newAccount (username, password, email="", apikey="") {
		<<4/28/09; 10:17:28 AM by DW
			<<Create a new account with the indicated username and password. The email address is optional.
				<<We have setup access for your API key to access the account creation API method. It is specced as follows:
				<<This function will create a new account.
				<<Method: GET or POST
				<<Formats: xml, json
					<< username. Required. The desired account ID.
					<< password. Required. The desired account password.
					<< email. Optional. The email address to set with the account setup.
					<< status. Either OK or ERROR with a code number and explanation.
					<< username. Confirmation of the username chosen.
					<< password. Confirmation of the password chosen.
				<<Let me know if you need anything else here. It returns a response code of 447 if the account username requested is already taken. It is not a method that has been heavily used, but it works fine for what we have been using it for.
	local (apiurl = "");
	apiurl = apiurl + trim.pushParams (username, password, apikey, '?');
	if email != "" {
		apiurl = apiurl + "&email=" + string.urlencode (email)};
	local (xmltext = tcp.httpreadurl (apiurl), xstruct);
	xml.compile (xmltext, @xstruct);
	<<scratchpad.xstruct = xstruct
	local (adrtrim = xml.getaddress (@xstruct, "trim"));
	local (adrstatus = xml.getaddress (adrtrim, "status"));
	return (xml.getattributevalue (adrstatus, "code") == 200)}
<<bundle //test code
	<<local (username = string.getrandompassword (10))
	<<local (password = string.getrandompassword (10))
	<<dialog.alert (newAccount (username, password))

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.