我正在尝试使用last.fm API(http://www.last.fm/api/mobileauth)restful使用Android Studio和Loopj Android AsyncHttpClient插件(http://loopj.com/android-async-http/)但我不断地得到404错误,但不明白为什么。下面的代码。我做错了什么?谢谢
RequestParams params = new RequestParams();
params.put("username", "myusername");
params.put("password", "mypassword");
params.put("api_key", "myapikey");
params.put("api_sig", "myapisecret");
LastFMRestClient.post("http://ws.audioscrobbler.com/2.0/", params,
new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
Log.e("MUSIC SERVICE", "Success");
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
String msg = "Object *" + statusCode + "*" + responseBody;
Log.e("MUSIC SERVICE", "Failed: " + msg);
// Outputs: Failed: Object *404*[B@17f1042c
}
public void onFinish() {
Log.e("MUSIC SERVICE", "Finished");
}
}
);
我缺少方法参数,并且没有在url上使用https!