Answer the question
In order to leave comments, you need to log in
I need to send a POST from android to the site, am I doing it right?
there is a link
http://ваывыаы.ru/js/main.js.php?act=zve%20$_POST[%27nickname%27]%20$_POST[%27text%27]%20==%20%20$_POST[%27music%27]
@Override
protected String doInBackground(Void... urls) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://выфвфывфыв.ru/js/main.js.php");
try {
List pairs = new ArrayList();
nick = editText1.getText().toString();
text = editText2.getText().toString();
music = editText3.getText().toString();
pairs.add(new BasicNameValuePair("nickname", nick ));
pairs.add(new BasicNameValuePair("text", text));
pairs.add(new BasicNameValuePair("music", music));
httppost.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = httpclient.execute(httppost);
responseString = EntityUtils.toString(response.getEntity());
} catch (Exception e) {}
return responseString;
Answer the question
In order to leave comments, you need to log in
In general, I solved my problem.
This code helped, who can explain in Russian what kind of apach is and what it does. I understand this because of https and some certificates of conformity.
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
DefaultHttpClient httpclient = new DefaultHttpClient(mgr, client.getParams());
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
final String url = "http://выфвфывфыв.ru/js/main.js.php";
HttpPost httppost = new HttpPost(url);
1. check if you understood correctly what and where to send through any rest client (I use postman)
2. use retrofit (I haven’t used HttpClient for three years, which is what I wish you)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question