-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
public class ContentExamples { | ||
public static void main { | ||
Twilio.init(ACCOUNT_SID, AUTH_TOKEN); | ||
createTwilioText(); | ||
} | ||
|
||
public static void createTwilioText() { | ||
Content.ContentCreateRequest createRequest = new Content.ContentCreateRequest("es", types); | ||
|
||
Content.TwilioText twilioText = new Content.TwilioText(); | ||
twilioText.setBody("text body"); | ||
|
||
Content.Types types = new Content.Types(); | ||
types.setTwilioText(twilioText); | ||
|
||
Map<String, String> variables = new HashMap<>(); | ||
variables.put("var1", "val1"); | ||
|
||
createRequest.setVariables(variables); | ||
createRequest.setFriendlyName("name"); | ||
|
||
Content newContent = Content.creator(createRequest).create(); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class PreviewMessagingExamples { | ||
public static void main { | ||
Twilio.init(ACCOUNT_SID, AUTH_TOKEN); | ||
sendBulkMessages(); | ||
} | ||
|
||
private static void sendBulkMessages() { | ||
Message.CreateMessagesRequest createMessagesRequest = new Message.CreateMessagesRequest(); | ||
List<String> toNumbers; // recipients numbers | ||
// Set from number | ||
PhoneNumber fromNumber; | ||
// Set list of number where you want to send bulk message. | ||
List<Message.MessagingV1Message> phoneList = new ArrayList<>(); | ||
for (String to: toNumbers) { | ||
Message.MessagingV1Message phone = new Message.MessagingV1Message(); | ||
phone.setTo(new PhoneNumber(to)); | ||
phoneList.add(phone); | ||
} | ||
createMessagesRequest.setFrom(fromNumber); | ||
createMessagesRequest.setBody("Bulk message to send"); | ||
createMessagesRequest.setMessages(phoneList); | ||
Message message = Message.creator(createMessagesRequest).create(); | ||
} | ||
|
||
} |