我遇到登录问题。我尝试了几个来自网络的例子,但没有为我工作。使用电子邮件和密码进行改造登录
JSON
{
"responseCode":1,
"responseCodeText":"ok",
"response":
{
"id":1234,
"email":"[email protected]",
"name":"name",
"lastname":"lastname",
"properties":[
//...
],
"rights":"admin",
"photo":"url",
"favorites":
[
//...
],
"token":"token"
}
}
我已经创建模型类从http://www.jsonschema2pojo.org/,所以它应该是确定。
接口
public interface LoginInterface {
@POST("login/{email}/{password}")
Call<UserResponse> login(@Path("email") String email, @Path("password") String password);
}
呼叫在活动
public void serviceInit() {
String email = edEmail.getText().toString();
String password = edPassword.getText().toString();
FactoryAPI.getInstanceLogin().login(email, password).enqueue(new Callback<UserResponse>() {
@Override
public void onResponse(Call<UserResponse> call, Response<UserResponse> response) {
if(response.isSuccessful()) {
Intent intent = new Intent(getContext(), AccountActivity.class);
startActivity(intent);
}
//TODO: load from sharedPreferences
}
@Override
public void onFailure(Call<UserResponse> call, Throwable t) {
Log.e("error", "points not loaded");
}
});
}
错误,我有
responseCodeText: “属性错误”
我收到了来自服务器的请求。我的电子邮件地址和密码是GET,不POST
感谢您的帮助
,你得到什么错误? –
你面临什么样的麻烦? –
请修改您的问题以包含错误的描述。 – theFunkyEngineer