Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mjg123
Created September 25, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjg123/6702fb03abd29fc39e0f23125c23a57e to your computer and use it in GitHub Desktop.
Save mjg123/6702fb03abd29fc39e0f23125c23a57e to your computer and use it in GitHub Desktop.
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