Created
September 25, 2020 14:29
-
-
Save mjg123/6702fb03abd29fc39e0f23125c23a57e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.twilio.demo; | |
import com.twilio.http.TwilioRestClient; | |
import com.twilio.rest.api.v2010.account.Message; | |
import com.twilio.type.PhoneNumber; | |
public class SmsDemo { | |
public static void main(String[] args) { | |
// Don't do this: | |
// Twilio.init( | |
// System.getenv("ACCOUNT_SID"), | |
// System.getenv("AUTH_TOKEN")); | |
// Do this instead | |
TwilioRestClient client = new TwilioRestClient.Builder( | |
System.getenv("ACCOUNT_SID"), | |
System.getenv("AUTH_TOKEN")).build(); | |
Message msg = Message.creator( | |
new PhoneNumber("+447723012710"), | |
new PhoneNumber("+44 7576 277909"), | |
"Hello from Twilio" | |
).create(client); // <-- pass the client in here | |
System.out.println(msg.getSid()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment