Created
October 21, 2018 17:18
-
-
Save shestakow1993/9cc3a950e74018734ed7ea5a0aa66682 to your computer and use it in GitHub Desktop.
sms sender to api open vox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.bgcrm.dyn; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
import ru.bgcrm.event.Event; | |
import ru.bgcrm.event.listener.DynamicEventListener; | |
import ru.bgcrm.event.process.ProcessChangedEvent; | |
import ru.bgcrm.model.BGException; | |
import ru.bgcrm.model.process.Process; | |
import ru.bgcrm.struts.form.DynActionForm; | |
import ru.bgcrm.util.sql.ConnectionSet; | |
import java.io.IOException; | |
public class SmsSender | |
extends DynamicEventListener { | |
public static final int STATUS_WAITIN_INGENEAR =13; | |
public static final int STATUS_CANCELED =14; | |
@Override | |
public void notify(Event e, ConnectionSet connectionSet) throws BGException { | |
if (e instanceof ProcessChangedEvent) { | |
ProcessChangedEvent event = (ProcessChangedEvent) e; | |
Process process = event.getProcess(); | |
if (process.getStatusId() == STATUS_WAITIN_INGENEAR) { | |
String resp = null; | |
try { | |
resp = sendSms("0502123456","zayavka_prinyata"); | |
} catch (IOException e1) { | |
e1.printStackTrace(); | |
} | |
DynActionForm form = event.getForm(); | |
form.getResponse().setMessage(resp); | |
} | |
} | |
} | |
public static String sendSms(String number,String text) throws IOException { | |
String query ="http://192.168.8.252/sendsms?username=admin&password=123qwertasdf&phonenumber="+number+"&message="+text+"&port=gsm-1.1&timeout=1200000"; | |
HttpClient client = new DefaultHttpClient(); | |
HttpGet request = new HttpGet(query); | |
HttpResponse response = client.execute(request); | |
return response.getStatusLine().toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment