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
import com.twilio.twiml.VoiceResponse | |
import com.twilio.twiml.voice.Pause | |
import com.twilio.twiml.voice.Record | |
import com.twilio.twiml.voice.Say | |
fun main(args: Array<String>){ | |
val record = Record.Builder() | |
.timeout(8).transcribe(true) | |
.recordingStatusCallback("https://webhook.site/a6340ade-e239-4276-b488-67f4428c6cab") |
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
public String messageBuilder(Price price, String symbol) { | |
return String.format("Here are the most up-to-date %s prices:\n" + | |
"\uD83C\uDF05 Open price of the day: $%s\n" + | |
"\uD83D\uDCC8 High price of the day: $%s\n" + | |
"\uD83D\uDCC9 Low price of the day: $%s\n" + | |
"\uD83D\uDD14 Current price: $%s\n" + | |
"\uD83D\uDCC6 Previous close price: $%s\n" + | |
"\uD83E\uDD1E Send another symbol.", | |
symbol, price.open, price.high, price.low, price.current, price.close); | |
} |
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) { |
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.google.common.util.concurrent.ListenableFuture; | |
import com.twilio.Twilio; | |
import com.twilio.rest.api.v2010.account.Message; | |
import com.twilio.type.PhoneNumber; | |
public class SmsDemo { | |
public static void main(String[] args) { |
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.google.common.util.concurrent.ListenableFuture; | |
import com.twilio.Twilio; | |
import com.twilio.rest.api.v2010.account.Message; | |
import com.twilio.type.PhoneNumber; | |
public class SmsDemo { | |
public static void main(String[] args) { |
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
// This method exists to work around a quirk in HttpServletRequest. For validation we only | |
// need to consider the parameters from the request *body*, but HSR.getParameterMap() *also* includes | |
// any parameters found in the query String, which will cause validation to fail. | |
// For POST requests, Twilio will not add any queryString params, but it's perfectly possible for a | |
// user to do that by including them in the webhook URL. | |
private HashMap<String, String> extractOnlyBodyParams(HttpServletRequest request, String validationUrl) throws IOException { | |
var allRequestParameters = request.getParameterMap(); | |
var queryStringParams = UriComponentsBuilder.fromUriString(validationUrl).build().getQueryParams(); |
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
import com.twilio.security.RequestValidator; | |
import java.util.HashMap; | |
import static spark.Spark.get; | |
import static spark.Spark.post; | |
public class RequestValidation { | |
public static void main(String[] args) { |
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
import com.twilio.security.RequestValidator; | |
import java.util.HashMap; | |
import static spark.Spark.get; | |
import static spark.Spark.post; | |
public class RequestValidation { | |
public static void main(String[] args) { |
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
import com.twilio.security.RequestValidator; | |
import java.util.HashMap; | |
import static spark.Spark.get; | |
import static spark.Spark.post; | |
public class RequestValidation { | |
public static void main(String[] args) { |
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
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import org.apache.commons.codec.binary.Base64; | |
import java.io.IOException; | |
import java.net.URI; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpRequest.BodyPublishers; | |
import java.net.http.HttpResponse.BodyHandlers; |
NewerOlder