Example usage for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder

List of usage examples for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder

Introduction

In this page you can find the example usage for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder.

Prototype

FormEncodingBuilder

Source Link

Usage

From source file:prue.Prueba.java

public static String Login(String Usuario, String Departamento, String Empresa, String Contrasena) {
    RequestBody formBody = new FormEncodingBuilder().add("user", Usuario).add("departamento", Departamento)
            .add("empresa", Empresa).add("password", Contrasena)

            .build();//from   w  ww. j a v a2  s  .co  m
    try {
        URL url = new URL("http://192.168.43.223:5000/Login");
        Request request = new Request.Builder().url(url).post(formBody).build();
        Response response = webClient.newCall(request).execute();
        String response_string = response.body().string();
        return response_string;
    } catch (MalformedURLException ex) {
        System.out.println(ex.toString());
    } catch (IOException ex) {
        System.out.println(ex.toString());
    }
    return null;
}

From source file:prue.Prueba.java

public static String Activo(String Usuario, String Departamento, String Empresa, String Contrasena,
        String nombreActivo, String descripcionActivo) {
    RequestBody formBody = new FormEncodingBuilder().add("user", Usuario).add("departamento", Departamento)
            .add("empresa", Empresa).add("password", Contrasena)

            .add("nombreActivo", nombreActivo).add("descripcionActivo", descripcionActivo)

            .build();//from  www  .j av a  2  s . com
    try {
        URL url = new URL("http://192.168.43.223:5000/addActivo");
        Request request = new Request.Builder().url(url).post(formBody).build();
        Response response = webClient.newCall(request).execute();
        String response_string = response.body().string();
        return response_string;
    } catch (MalformedURLException ex) {
        System.out.println(ex.toString());
    } catch (IOException ex) {
        System.out.println(ex.toString());
    }
    return null;
}

From source file:prue.Prueba.java

public static String Devolver(String Usuario, String Departamento, String Empresa, String Contrasena) {
    RequestBody formBody = new FormEncodingBuilder().add("user", Usuario).add("departamento", Departamento)
            .add("empresa", Empresa).add("password", Contrasena)

            .build();//from w  ww. java 2  s. c o m
    try {
        URL url = new URL("http://192.168.43.223:5000/vista");//IP 192.168.43.223
        Request request = new Request.Builder().url(url).post(formBody).build();
        Response response = webClient.newCall(request).execute();
        String response_string = response.body().string();
        return response_string;
    } catch (MalformedURLException ex) {
        System.out.println(ex.toString());
    } catch (IOException ex) {
        System.out.println(ex.toString());
    }
    return null;
}

From source file:prue.Prueba.java

public static String Modificar(String id, String nuevadescripcion) {
    RequestBody formBody = new FormEncodingBuilder().add("id", id).add("descripcion", nuevadescripcion)

            .build();/*from  w w w  .  j a  v  a 2s.c  o m*/
    try {
        URL url = new URL("http://192.168.43.223:5000/modificar");//IP 192.168.43.223
        Request request = new Request.Builder().url(url).post(formBody).build();
        Response response = webClient.newCall(request).execute();
        String response_string = response.body().string();
        return response_string;
    } catch (MalformedURLException ex) {
        System.out.println(ex.toString());
    } catch (IOException ex) {
        System.out.println(ex.toString());
    }
    return null;
}

From source file:pw.isdust.isdust.Http.java

License:Open Source License

public String post_string(String url, String postbody) throws IOException {
    //POST/*from www .  ja  v a 2 s.  c  o m*/
    String mstring_fenge1[] = postbody.split("&");

    FormEncodingBuilder mFormEncodingBuilder = new FormEncodingBuilder();
    Request.Builder a = new Request.Builder();

    RequestBody mformBody;

    for (int i = 0; i < mstring_fenge1.length; i++) {
        String mstring_fenge2[] = mstring_fenge1[i].split("=");
        if (mstring_fenge2.length == 2) {
            mFormEncodingBuilder.add(mstring_fenge2[0], mstring_fenge2[1]);
        }
        if (mstring_fenge2.length == 1) {
            mFormEncodingBuilder.add(mstring_fenge1[i].replace("=", ""), "");
        }
    }
    mformBody = mFormEncodingBuilder.build();
    //String b=mformBody.toString();
    //POST
    System.out.println(mformBody.toString());

    //??
    Request request = new Request.Builder().url(url).post(mformBody).header("User-Agent",
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36")
            .build();

    Response response_1;
    response_1 = mHTTP.newCall(request).execute();
    return response_1.body().string();

}

From source file:pw.isdust.isdust.Http.java

License:Open Source License

public String post_string_noturlencode(String url, String postbody) throws IOException {
    //POST/*from  ww w  .ja v  a  2s  .  co  m*/
    String mstring_fenge1[] = postbody.split("&");

    FormEncodingBuilder mFormEncodingBuilder = new FormEncodingBuilder();
    Request.Builder a = new Request.Builder();

    RequestBody mformBody;

    for (int i = 0; i < mstring_fenge1.length; i++) {
        String mstring_fenge2[] = mstring_fenge1[i].split("=");
        if (mstring_fenge2.length == 2) {
            mFormEncodingBuilder.addEncoded(mstring_fenge2[0], mstring_fenge2[1]);
        }
        if (mstring_fenge2.length == 1) {
            mFormEncodingBuilder.addEncoded(mstring_fenge1[i].replace("=", ""), "");
        }
    }
    mformBody = mFormEncodingBuilder.build();
    //String b=mformBody.toString();
    //POST
    System.out.println(mformBody.toString());

    //??
    Request request = new Request.Builder().url(url).post(mformBody).header("User-Agent",
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36")
            .build();

    Response response_1;
    response_1 = mHTTP.newCall(request).execute();
    return response_1.body().string();

}

From source file:pw.isdust.isdust.Http.java

License:Open Source License

public String post_string(String url, String postbody, final String bianma) throws IOException {
    //POST/* w w w  . j a  v a  2 s. c  o m*/
    String mstring_fenge1[] = postbody.split("&");
    FormEncodingBuilder mFormEncodingBuilder = new FormEncodingBuilder();
    RequestBody mformBody;
    for (int i = 0; i < mstring_fenge1.length; i++) {
        String mstring_fenge2[] = mstring_fenge1[i].split("=");
        if (mstring_fenge2.length == 2) {
            mFormEncodingBuilder.addEncoded(mstring_fenge2[0], mstring_fenge2[1]);
        }
    }
    mformBody = mFormEncodingBuilder.build();
    //POST
    System.out.println(mformBody.toString());

    //??
    Request request = new Request.Builder().url(url).post(mformBody).build();

    Response response_1;
    if (bianma == "gb2312") {
        response_1 = mHTTP.newCall(request).execute();
        return new String(response_1.body().bytes(), "gb2312");
    }

    return null;

}

From source file:reportes.c_op.java

String agregar(String text) {
    RequestBody formBody = new FormEncodingBuilder().add("dato1", text).build();
    String g = enviardato("matrizagregar", formBody);
    System.out.println(g);//from  ww  w. ja  v  a  2  s  .  co  m
    return g;

    // String r = getString("listasm", formBody); 
    // System.out.println(r + "---");
}

From source file:reportes.c_op.java

String buscar(String text) {
    RequestBody formBody = new FormEncodingBuilder().add("dato1", text).build();
    return enviardato("listasb", formBody);
    // String r = getString("listasm", formBody); 
    // System.out.println(r + "---");
}

From source file:reportes.c_op.java

void buscarletra(String text) {
    RequestBody formBody = new FormEncodingBuilder().add("dato1", text).build();
    String tam = enviardato("matrizbletra", formBody);
    //System.out.println(tam);
    System.out.println("Datos");
    for (int i = Integer.parseInt(tam) - 1; i >= 0; i--) {
        RequestBody formBody1 = new FormEncodingBuilder().add("dato1", text).add("dato2", String.valueOf(i))
                .build();//from w w w  .j a  v  a 2s .  c o  m

        String mos = enviardato("matrizbletra1", formBody1);
        System.out.print(mos + "  ");

    }
    //JOptionPane.showMessageDialog(null, tam);
}