这里的httpPost()java类,
public String getXmlFromUrl_NewRegistration(String url,
String username, String firstname, String lastname, String email,
String password) {
String json = null;
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://aleedex.biz/game/users.php?action=new");
String postParameter = "username=" + username + "&firstname="
+ firstname + "&lastname=" + lastname + "&email=" + email
+ "&password=" + password;
try {
httpPost.setEntity(new StringEntity(postParameter));
} catch (Exception e) {
}
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
json = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
} catch (ClientProtocolException e) {
} catch (IOException e) {
json = null;
}
Log.d("json", json);
return json;
}
在httpGet()中也使用相同的参数,如用户名,名字,姓氏,电子邮件,密码
如何通过httpGet()在该链接http://aleedex.biz/game/users.php?action=new
答案 0 :(得分:0)
在这里你可以将帖子参数附加到网址,然后拨打电话就可以了
`HttpGet _getrequest=new HttpGet("http://aleedex.biz/game/users.php? action=new&"+postParameter);
HttpResponse httpResponse = httpClient.execute(_getrequest);
HttpEntity httpEntity = httpResponse.getEntity();
json = EntityUtils.toString(httpEntity);`
尝试这个我认为这应该有用。
答案 1 :(得分:0)
我已遵循该教程并解决了我的问题How to connect Android with PHP, MySQL