1

ここの 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

4

2 に答える 2

0

私はそのチュートリアルに従って、私の問題を解決しました AndroidとPHP、MySQLを接続する方法

于 2014-04-10T06:35:19.950 に答える
0

ここで、post パラメーターを URL に追加してから、呼び出しを行うことができます。

`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);`

これを試してみてください。これでうまくいくはずです。

于 2013-04-19T06:09:54.990 に答える