我遇到登錄問題。我嘗試了幾個來自網絡的例子,但沒有爲我工作。使用電子郵件和密碼進行改造登錄
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