| 10 | import java.util.Random; |
| 11 | |
| 12 | public class Hangover { |
| 13 | |
| 14 | public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID"); |
| 15 | public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN"); |
| 16 | |
| 17 | public static final String YOUR_NUMBER = "1231231231"; |
| 18 | public static final String BOSS_NUMBER = "3213213213"; |
| 19 | |
| 20 | public static void main(String[] args) throws TwilioRestException { |
| 21 | |
| 22 | TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); |
| 23 | |
| 24 | String[] randomMessages = { |
| 25 | "Locked out", |
| 26 | "Pipes broke", |
| 27 | "Food poisoning", |
| 28 | "Not feeling well" |
| 29 | }; |
| 30 | |
| 31 | int randomIndex = new Random().nextInt(randomMessages.length); |
| 32 | String finalMessage = (randomMessages[randomIndex]); |
| 33 | |
| 34 | List<NameValuePair> params = new ArrayList<NameValuePair>(); |
| 35 | params.add(new BasicNameValuePair("Body", "Gonna work from home. " + finalMessage)); |
| 36 | params.add(new BasicNameValuePair("From", YOUR_NUMBER)); |
| 37 | params.add(new BasicNameValuePair("To", BOSS_NUMBER)); |
| 38 | |
| 39 | MessageFactory messageFactory = client.getAccount().getMessageFactory(); |
| 40 | Message message = messageFactory.create(params); |
| 41 | System.out.println(message.getSid()); |
| 42 | } |
| 43 | } |
| 44 |
nothing calls this directly
no outgoing calls
no test coverage detected