public Api createAccount ( String name , String eMail , String realname , boolean mailpassword , String reason , String language ) throws Exception { String createtoken = "?" ; if ( getVersion ( ) . compareToIgnoreCase ( "Mediawiki 1.27" ) >= 0 ) { Api apiResult = this . getQueryResult ( "&meta=tokens&type=createaccount" ) ; super . handleError ( apiResult ) ; createtoken = apiResult . getQuery ( ) . getTokens ( ) . getCreateaccounttoken ( ) ; } Api api = null ; if ( getVersion ( ) . compareToIgnoreCase ( "Mediawiki 1.27" ) >= 0 ) { Map < String , String > lFormData = new HashMap < String , String > ( ) ; lFormData . put ( "createtoken" , createtoken ) ; lFormData . put ( "username" , name ) ; lFormData . put ( "email" , eMail ) ; lFormData . put ( "realname" , realname ) ; lFormData . put ( "mailpassword" , mailpassword ? "1" : "0" ) ; lFormData . put ( "reason" , reason ) ; lFormData . put ( "createcontinue" , "1" ) ; String params = "" ; api = getActionResult ( "createaccount" , params , null , lFormData ) ; } else { String params = "&name=" + this . encode ( name ) ; params += "&email=" + this . encode ( eMail ) ; params += "&realname=" + this . encode ( realname ) ; params += "&mailpassword=" + mailpassword ; params += "&reason=" + this . encode ( reason ) ; params += "&token=" ; api = getActionResult ( "createaccount" , params ) ; handleError ( api ) ; String token = api . getCreateaccount ( ) . getToken ( ) ; params += token ; api = getActionResult ( "createaccount" , params ) ; } return api ; }
create the given user account