我正在为Android开发一个简单的基于http的应用程序。
我在服务器上有login.php,并且正在使用以下值向其发送请求。
Uri.Builder loginUri =Uri.parse(LOGIN_API_URL).buildUpon();
loginUri.appendQueryParameter("username", username);
loginUri.appendQueryParameter("password", "FXK3guidUGU=");
aQuery.ajax(loginUri.build().toString(), JSONObject.class,loginResponse);
请求可以正常进行,但是PHP代码收到的密码为FXK3guidUGU
。可能是由于equals(=)字符所致。我如何确保PHP收到包含equals(=)字符的密码?
这是我的PHP代码,用于过滤密码:
$password = filter_input(INPUT_GET, 'password', FILTER_SANITIZE_SPECIAL_CHARS);
谢谢你的帮助。
尝试使用URLEncoder
Uri.Builder loginUri =Uri.parse(LOGIN_API_URL).buildUpon();
loginUri.appendQueryParameter("username", username);
loginUri.appendQueryParameter("password", URLEncoder.encode("FXK3guidUGU=", "UTF-8"));
aQuery.ajax(loginUri.build().toString(), JSONObject.class,loginResponse);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句