最初の Web サービス呼び出しは以下のようになります
RestClient client = new RestClient(LOGIN_URL);
client.AddParam("accountType", "GOOGLE");
client.AddParam("source", "tboda-widgalytics-0.1");
client.AddParam("Email", _username);
client.AddParam("Passwd", _password);
client.AddParam("service", "analytics");
client.AddHeader("GData-Version", "2");
try {
client.Execute(RequestMethod.POST);
} catch (Exception e) {
e.printStackTrace();
}
String response = client.getResponse();
応答を解析した後、別の Web サービス呼び出しを実行する場合は、別の URL とパラメーターを使用して RestClient の別のオブジェクトを作成し、以下のように execute メソッドを呼び出します。
RestClient client1 = new RestClient(GET_INFO_URL);
client1.AddParam("userid", "123");
try {
client1.Execute(RequestMethod.POST);
} catch (Exception e) {
e.printStackTrace();
}
String response1 = client1.getResponse();