我正在使用Retrofit Lib。
我的代码是public class TestPostData {
final String username;
final String password;
TestPostData(String username, String password) {
this.username = username;
this.password = password;
}
}
,接口为
interface Test {
@POST("/post.php")
void testMethod(@Body TestPostData postbody,@Query("qName") String qName,Callback<Response> callback);
}
<<p> 其他适配器/strong> RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(TEST_URL)
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
,称其为
testObj.testMethod(new TestPostData("myusername", "mypassword"),"myname",new Callback<Response>() { ..............
在服务器端,我得到$_POST数组为空。如何在服务器端获得用户名和密码值。我得到了name值
我知道这有点晚了,但要在PHP中读取请求正文,你可以这样做:
<?php
echo file_get_contents('php://input');
?>