내 안드로이드 응용 프로그램에서이 같은 요청을 할 찾고 야 :발리로 POST 요청을하는
String url = "http://example.com:8080/rest/items/wakeup";
StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(MjpegActivity.this,response,Toast.LENGTH_LONG).show();
//This code is executed if the server responds, whether or not the response contains data.
//The String 'response' contains the server's response.
}
},
new Response.ErrorListener() { //Create an error listener to handle errors appropriately.
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MjpegActivity.this,error.toString(),Toast.LENGTH_LONG).show();
//This code is executed if there is an error.
}
}){
@Override
protected Map<String, String> getParams() {
Map<String, String> MyData = new HashMap<String, String>();
MyData.put("AAAAAA", "BBBBBB"); //Add the data you'd like to send to the server.
return MyData;
}
};
RequestQueue MyRequestQueue = Volley.newRequestQueue(this);
MyRequestQueue.add(MyStringRequest);
}
이 여기에서 가져온 것입니다
curl --header "Content-Type: text/plain" --request POST --data "ON" http://example.com:8080/rest/items/wakeup
지금까지 나는이있다 : https://www.simplifiedcoding.net/android-volley-post-request-tutorial/ 누군가이 작품을 만드는 방법을 알아낼 수 있습니까? 나는 내가 보낸 데이터가 AAAAAA와 BBBBBB가 어디로가는 지 알지만 실제로 어떻게 문자열을 "ON"으로 보낼 수 있는지 이해하지 못합니다.
당신이 "ON"문자열 무엇을 의미합니까 (당신이 게시 할 파일과 i.php 교체)를 보내? 너는 그것을 명확히 할 수 있니? 이 매개 변수를 보내는 방법을 알고 싶습니까? –
두 번째 예제 인 [대답은 여기] (http://stackoverflow.com/a/26270185/1270789)를 참조하십시오. getParams()가 아닌'getBody()'에 대해서'return String ("ON"). getBytes(); –
check http://stackoverflow.com/questions/31552242/sending-http-post-request-with-android –