Cakephp で作成した Web サイトがあります。アプリで形成されたいくつかの値をこの Web サイトに渡したいです。ブラウザにまったく同じ URL を入力すると、機能します。
URL は次のようなものです: www.something.com/function/add/value
これがGETメソッドなのかPOSTメソッドなのか非常に混乱していますか?そして、どうすればそれを行うことができますか?
問題は、この URL を変更したり、そこに POST または GET PHP スクリプトを配置して値を取得したりすることはできないということです。したがって、基本的には、これらのパラメーターを使用して URL を呼び出すだけです。
これは私のコードです:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = null;
try {
httppost = new HttpPost("www.something.com/function/add/" + URLEncoder.encode(txtMessage.getText().toString(), "UTF-8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
try {
ResponseHandler<String> responseHandler = new BasicResponseHandler();
httpclient.execute(httppost, responseHandler);
} catch (ClientProtocolException e) {
} catch (IOException e) {
}