게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
살려주세요... 안드로이드 JSONObject를 PHP로 넘기는데...
게시물ID : programmer_19325짧은주소 복사하기
작성자 : 내밑으로오게나
추천 : 0
조회수 : 501회
댓글수 : 4개
등록시간 : 2016/12/16 15:28:57
HttpURLConnection객체로 JSONOjbect를 Post방식으로 
PHP로 넘겼는데 도무지 넘어 오지않네요...
===============================================================================안드로이드 소스코드
JSONObject result = null;

try{
URL urlCon = new URL(strUrl);
HttpURLConnection httpCon = (HttpURLConnection) urlCon.openConnection();

String json = post.toString();

httpCon.setRequestProperty("Accept", "application/json");
httpCon.setRequestProperty("Content-type", "application/json");
httpCon.setRequestProperty("Content-type","application/x-www-form-urlencoded");

httpCon.setDoOutput(true);
httpCon.setDoInput(true);
httpCon.setUseCaches(false);
httpCon.setDefaultUseCaches(false);

OutputStream os = httpCon.getOutputStream();
os.write(json.getBytes("utf-8"));
os.flush(); // 여기까지 JSONObject 값을 넘기는데 PHP $_POST에 아무것도 들어 있지 않아요

InputStream is = httpCon.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));

String line;
StringBuilder strResult = new StringBuilder();
while ((line = reader.readLine()) != null)
strResult.append(line);

httpCon.disconnect();
result = new JSONObject(strResult.toString());
} catch (UnsupportedEncodingException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
} catch (JSONException e)
{
e.printStackTrace();
}

============================================PHP 소스코드

전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호