AndoroidとPHPでデータ通信をしたいと考えています。
HTTP通信はできているのですが、パラメータがうまく渡せません。
コードは下記サイトを参考にして記述しましたが、誤っている箇所がございますでしょうか?
http://qiita.com/kaikusakari/items/b1dd02803bb16956010a
PHP
1$conferenceKey = $_POST["conferenceKey"]; 2$recordValue = $_POST["recordValue"];
Andoroid
1try{ 2 urlConnection = (HttpURLConnection) new URL(url).openConnection(); 3 urlConnection.setRequestMethod("POST"); 4 urlConnection.setInstanceFollowRedirects(false); 5 urlConnection.setRequestProperty("Accept-Language", "jp"); 6 urlConnection.setDoOutput(true); 7 urlConnection.setRequestProperty("Content-Type", "application/json; charset=utf-8"); 8 OutputStream os = urlConnection.getOutputStream(); 9 PrintStream ps = new PrintStream(os); 10 String parameterString = new String("conferenceKey='A1'&recordValue='B2'"); 11 ps.print(parameterString); 12 ps.close(); 13 BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); 14 15 String line; 16 while((line = br.readLine()) != null){ 17 stringBuffer.append(line); 18 } 19}
パラメータ値には'A1','B2'といった値を渡しているつもりですが、受け取れておりません。
間違っている箇所がありましたらご指摘いただきたいです。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/19 07:40
2017/04/19 08:02
2017/04/19 08:08
2017/04/19 08:17
2017/04/19 09:06