I have the url like this enter link description here
I want to read status and sms from response. How can I do it ? I try to use this code, but it do not work perfect
new Thread(new Runnable() {
URL url = null;
int code;
@Override
public void run() {
try {
url = new URL("http://domscanner.ru/api/poll/login?phone=79232893050");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.build();
Call call = client.newCall(request);
Response response = call.execute();
code = response.code();
if (!response.isSuccessful()) {
code = response.code();
}
String results;
Log.i("TEST", "code " + code);
if(code == 200) {
results = response.body().toString();
} else {
results = "nothing";
}
Log.i("TEST ", "result " + results);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
in log
code 200
result
okhttp3.internal.http.RealResponseBody@90b58f4