gpt4 book ai didi

android - 在 Android 中发布基于 webservice 的请求

转载 作者:行者123 更新时间:2023-11-29 00:21:14 25 4
gpt4 key购买 nike

我刚开始使用 WebServices

 Method Type: POST

Request Parameters : {loginid:'xxxx@gmail.com', password:'yyyyy'}

我试过如下:

  JSONObject jObj = new JSONObject();
try {
jObj.put("loginid", email.getText());
jObj.put("password", password.getText());
}

如何为它编写 JSON 代码。

最佳答案

JSONObject jObj = new JSONObject();
try {
jObj.put("loginid", email.getText());
jObj.put("password", password.getText());
}

HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("www.yoursite.com/page");
StringEntity se = new StringEntity(jObj.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
post.setEntity(se);
client.execute(post);

关于android - 在 Android 中发布基于 webservice 的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23028642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com