AndroidアプリケーションをJavaで作成しようとしていますが、他のPOST情報と一緒にXMLを送信する必要があります
文字列にXMLが含まれていない場合、 XMLのみXMLのためのPOST-キーが装着されている内容ではなくAndroidからXML to PHPページを送信
は、私は次のコード
// Check if there is nothing to input
if (input == null)
input = new HashMap<String, String>();
// Add the mobile's ID
input.put("MobileID", ((TelephonyManager)cxt.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId());
// The string for the input
String strInput = "";
// For each input
for (Entry<String, String> ent : input.entrySet()) {
// Check if the string is not empty
if (strInput.length() > 0)
strInput += "&";
// Add to the String
strInput += URLEncoder.encode(ent.getKey(), Encoding.UTF_8.name()) + "=" + URLEncoder.encode(ent.getValue(), Encoding.UTF_8.name());
}
// Open the connection and setup default values
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
conn.setRequestMethod("POST");
// Set the RequestProperties
conn.setRequestProperty("Authorization", "Basic " + CtrSettings.getInstance().getAuthentication());
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", strInput.getBytes().length + "");
// Set the booleans for the connection
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
// Create the input
DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
dos.write(strInput.getBytes());
dos.flush();
dos.close();
// Return the connection
return conn;
を使用してPOST-情報を送信しています含まれている誰もが私が間違っているの何、私に言うことはできますか?
Content-Typeまたは?
XMLをエスケープして別のXML文字列内で使用することもできますが、PHPでXML(およびXML-tags)を認識させたくない場合は、デプスペクティブにしてください(
)。
私は他のポスト情報を持っているとき、それはXMLではありませんか? – The87Boy
それはトリックをしなかった:( – The87Boy