Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pro.izcali.apptojoc.listenersNotificationsFirebase;
- import android.os.AsyncTask;
- import android.util.Log;
- import org.json.JSONObject;
- import okhttp3.MediaType;
- import okhttp3.OkHttpClient;
- import okhttp3.Request;
- import okhttp3.RequestBody;
- import okhttp3.Response;
- public class SendMail {
- public static void sendMailTo(String descripcion, String tipo_usuario, String asunto, String from, String to) {
- // Log.d(TAG, "sendNotification: TOKEN "+regToken);
- final String descripcion_f = descripcion;
- final String tipo_usuario_f = tipo_usuario;
- final String asunto_f = asunto;
- final String from_f = from;
- final String to_f = to;
- final MediaType JSON
- = MediaType.parse("application/json; charset=utf-8");
- new AsyncTask<Void,Void,Void>(){
- @Override
- protected Void doInBackground(Void... params) {
- try {
- OkHttpClient client = new OkHttpClient();
- JSONObject json=new JSONObject();
- json.put("descripcion",descripcion_f);
- json.put("usuario",tipo_usuario_f);
- json.put("asunto", asunto_f);
- json.put("from", from_f);
- json.put("to", to_f);
- RequestBody body = RequestBody.create(JSON, json.toString());
- Request request = new Request.Builder()
- .url("https://apptojo.izcali.pro/api/v1/mail/send_mail.php?")
- .post(body)
- .build();
- Response response = client.newCall(request).execute();
- String finalResponse = response.body().string();
- }catch (Exception e){
- //Log.d(TAG,e+"");
- }
- return null;
- }
- }.execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement