MyPW Example: Java


This example is based on the Apache XML-RPC Java library.
Sample Code
    import org.apache.xmlrpc.XmlRpcClientLite;

    XmlRpcClientLite xmlrpc = new XmlRpcClientLite ("https://services.mypw.com/RPC2");

    Hashtable ht = new Hashtable();
    ht.put("siteid",     mySiteID);
    ht.put("authkey",    myAuthkey);
    ht.put("tokenid",    tokenid);
    ht.put("tokenvalue", tokenvalue);

    Vector params = new Vector ();
    params.addElement (ht);

    Hashtable result = (Hashtable) xmlrpc.execute ("auth.auth", params);
    int code = (Integer)result.get("code");
    String message = (String)result.get("message");

    if (code == 0) { 
        // success!
    }
    else { 
        // failure, see message for details
        System.err.println("Error: " + message);
    }