|
10 | 10 | import com.twilio.sdk.TwilioRestException; |
11 | 11 | import com.twilio.sdk.TwilioRestResponse; |
12 | 12 | import com.twilio.sdk.resource.factory.CallFactory; |
13 | | -import com.twilio.sdk.resource.factory.SmsFactory; |
| 13 | +import com.twilio.sdk.resource.factory.MessageFactory; |
14 | 14 | import com.twilio.sdk.resource.instance.Account; |
15 | 15 | import com.twilio.sdk.resource.instance.AvailablePhoneNumber; |
16 | 16 | import com.twilio.sdk.resource.instance.Call; |
@@ -80,14 +80,14 @@ public static void main(String[] args) throws TwilioRestException { |
80 | 80 | Call call = callFactory.create(callParams); |
81 | 81 | System.out.println(call.getSid()); |
82 | 82 |
|
83 | | - // Send an sms |
84 | | - SmsFactory smsFactory = mainAccount.getSmsFactory(); |
85 | | - Map<String, String> smsParams = new HashMap<String, String>(); |
86 | | - smsParams.put("To", "5105551212"); // Replace with a valid phone number |
87 | | - smsParams.put("From", "(510) 555-1212"); // Replace with a valid phone |
88 | | - // number in your account |
89 | | - smsParams.put("Body", "This is a test message!"); |
90 | | - smsFactory.create(smsParams); |
| 83 | + // Send an sms (using the new messages endpoint) |
| 84 | + MessageFactory messageFactory = mainAccount.getMessageFactory(); |
| 85 | + List<NameValuePair> messageParams = new ArrayList<NameValuePair>(); |
| 86 | + messageParams.add(new BasicNameValuePair("To", "5105551212")); // Replace with a valid phone number |
| 87 | + messageParams.add(new BasicNameValuePair("From", "(510) 555-1212")); // Replace with a valid phone |
| 88 | + // number in your account |
| 89 | + messageParams.add(new BasicNameValuePair("Body", "This is a test message!")); |
| 90 | + messageFactory.create(messageParams); |
91 | 91 |
|
92 | 92 | // Search for available phone numbers & then buy a random phone number |
93 | 93 | AvailablePhoneNumberList phoneNumbers = mainAccount |
|
0 commit comments