1+ import com .twilio .sdk .TwilioRestClient ;
2+ import com .twilio .sdk .TwilioRestException ;
3+ import com .twilio .sdk .resource .factory .MessageFactory ;
4+ import com .twilio .sdk .resource .instance .Message ;
5+ import org .apache .http .NameValuePair ;
6+ import org .apache .http .message .BasicNameValuePair ;
7+
8+ import java .util .ArrayList ;
9+ import java .util .List ;
10+ import java .util .Random ;
11+
12+
13+ public class SmackMyBitch {
14+
15+ public static final String ACCOUNT_SID = System .getenv ("TWILIO_ACCOUNT_SID" );
16+ public static final String AUTH_TOKEN = System .getenv ("TWILIO_AUTH_TOKEN" );
17+
18+ public static final String YOUR_NUMBER = "1231231231" ;
19+ public static final String HER_NUMBER = "3213213213" ;
20+
21+ public static void main (String [] args ) throws TwilioRestException {
22+
23+ TwilioRestClient client = new TwilioRestClient (ACCOUNT_SID , AUTH_TOKEN );
24+
25+ String [] randomMessages = {
26+ "Working hard" ,
27+ "Gotta ship this feature" ,
28+ "Someone fucked the system again" ,
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" , "Late at work. " + finalMessage ));
36+ params .add (new BasicNameValuePair ("From" , YOUR_NUMBER ));
37+ params .add (new BasicNameValuePair ("To" , HER_NUMBER ));
38+
39+ MessageFactory messageFactory = client .getAccount ().getMessageFactory ();
40+ Message message = messageFactory .create (params );
41+ System .out .println (message .getSid ());
42+ }
43+ }
0 commit comments