@Test @Ignore public void vmsSendTtsTest() throws SmsapiException { final long time = (new Date().getTime() / 1000) + 86400; final String tts = "to jest test"; VMSSend action = apiFactory.actionSend().setTts(tts).setTo(numberTest).setInterval(300).setDateSent(time); StatusResponse result = action.execute(); System.out.println("VmsSend:"); ids = new String[result.getCount()]; int i = 0; for (MessageResponse item : result.getList()) { if (!item.isError()) { renderMessageItem(item); ids[i] = item.getId(); i++; } } if (ids.length > 0) { writeIds(ids); } }
@Test @Ignore public void vmsSendFileTest() throws FileNotFoundException, SmsapiException { final long time = (new Date().getTime() / 1000) + 86400; final File fileAudio = new File("src/test/java/pl/smsapi/test/voice_small.wav"); VMSSend action = apiFactory.actionSend().setFile(fileAudio).setTo(numberTest).setDateSent(time); StatusResponse result = action.execute(); System.out.println("VmsSend:"); if (result.getCount() > 0) { ids = new String[result.getCount()]; } int i = 0; for (MessageResponse item : result.getList()) { if (!item.isError()) { renderMessageItem(item); ids[i] = item.getId(); i++; } } if (ids.length > 0) { writeIds(ids); } }
@Test @Ignore public void vmsGetTest() throws SmsapiException { System.out.println("VmsGet:"); ids = readIds(); if (ids != null) { VMSGet action = apiFactory.actionGet().ids(ids); StatusResponse result = action.execute(); for (MessageResponse item : result.getList()) { renderMessageItem(item); } } }
public void sendSms(String message, String phoneNumber) { Client client = getClientSession(); try { SmsFactory smsApi = new SmsFactory(client); SMSSend action = smsApi .actionSend() .setText(message) .setTo(phoneNumber) .setSender("Info"); // Pole nadawcy lub typ wiadomość 'ECO', '2Way' StatusResponse result = action.execute(); for (MessageResponse status : result.getList()) { System.out.println(status.getNumber() + " " + status.getStatus()); } } catch (ActionException e) { /** * Błędy związane z akcją (z wyłączeniem błędów 101,102,103,105,110,1000,1001 i 8,666,999,201) * http://www.smsapi.pl/sms-api/kody-bledow */ System.out.println(e.getMessage()); } catch (HostException e) { /* błąd po stronie servera lub problem z parsowaniem danych * * 8 - Błąd w odwołaniu * 666 - Wewnętrzny błąd systemu * 999 - Wewnętrzny błąd systemu * 201 - Wewnętrzny błąd systemu */ System.out.println(e.getMessage()); } catch (SmsapiException e) { System.out.println(e.getMessage()); } }