因为我可以通过android上的改造来接收数据,我是android编程新手,添加库,但不是如何发出请求,我需要帮助,然后创建接口。
1.interface常数:
public interface Constants {
String URL = "http://mydress.com/api/signin/signin.php";
}
2.interface LoginRetrofit:
public interface LoginRetrofit {
@POST(Constants.URL)
void getUser(@Body JSONObject searchstring, Callback<JSONObject> callBack);
}
当我提出数据请求时
答案 0 :(得分:0)
Constants.class:
public interface Constants {
String URL = "/api/signin/signin.php";
}
LoginRetrofit.class:
public interface LoginRetrofit {
@POST(Constants.URL)
void getUser(@Body JSONObject searchstring, Callback<JSONObject> callBack);
}
要调用此API方法的类:
//Build RestAdapter
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://mydress.com")
.build();
//Create API service
LoginRetrofit service = restAdapter.create(LoginRetrofit.class);
//Invoke method. Parameters must be defined earlier of course
service.getUser(searchstring, callBack);