Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

Java posts

  • By Matthew Gilliard
    Three ways to use Jackson for JSON in Java Three ways to use Jackson for JSON in Java

    If you’re working in a statically-typed language like Java then dealing with JSON can be tricky. JSON doesn’t have type definitions and is lacking some features which we would like - there’s only strings, numbers, booleans and null, so to store other types (like dates or times) we’re forced to use a string-based convention. Despite its shortcomings, JSON is the most common format for APIs on the web so we need a way to work with it in Java.

    Jackson is one of the most popular Java JSON libraries, and is the one I use most frequently. In this post I’ll pick a fairly complex JSON document and three queries which I want to make using Jackson. I’ll compare three different approaches:

    1. Tree model
    2. Data binding
    3. Path queries

    All the code used in this post is in this repository. It’ll work with Java 8 onwards.

    Other Java Libraries …

    Read More
  • By Matthew Gilliard
    Two ways to use Gson for JSON in Java Two ways to use Gson for JSON in Java

    If you’re working in a statically-typed language like Java then dealing with JSON can be tricky. JSON doesn’t have type definitions and is lacking some features which we would like - there’s only strings, numbers, booleans and null, so to store other types (like dates or times) we’re forced to use a string-based convention. Despite its shortcomings, JSON is the most common format for APIs on the web so we need a way to work with it in Java.

    Gson is one of the most popular Java JSON libraries. In this post I’ll pick a fairly complex JSON document and three queries which I want to make using Gson. I’ll compare two different approaches:

    1. Tree model
    2. Data binding

    All the code used in this post is in this repository. It’ll work with Java 8 onwards.

    Other Java Libraries for working with JSON

    The most popular Java libraries for …

    Read More
  • By Matthew Gilliard
    Open and Click Tracking for Email using Java and Twilio SendGrid Open and Click Tracking for Email using Java and Twilio SendGrid

    I covered sending emails from Java using the Twilio SendGrid API before, but for important emails it can be vital to know whether recipients have opened your mail, and whether they have clicked on the links in it. You can do this using the SendGrid Event Webhook, which works by sending HTTP requests to a URL you provide. In this post I’ll show how to configure this with Twilio SendGrid and build a Java web application to handle the webhooks and record your recipients’ activity.

    Before you start

    You will need

    • Java - version 8 or newer. I like to use SDKMAN! to manage Java installations
    • Ngrok
    • A Twilio SendGrid account - sign up here if you don’t have one already.

    Creating the application

    If you prefer to skip the coding and instead try things out you can find the code for this application on GitHub, and …

    Read More
  • By Matthew Gilliard
    Validating phone numbers in a Spring Boot app using the Twilio Lookup API Validating phone numbers in a Spring Boot app using the Twilio Lookup API

    Many user registration flows these days require a user to provide a phone number, either for two-factor authentication or to provide notifications and updates.

    To check that the number provided by your user is valid, you might reach for a regular expression, but that won’t be reliable - phone numbers are complicated, and it won’t tell you if the number provided is actually reachable. There are multiple levels of validation possible - in this post I’ll show how to use the Twilio Lookup API to check if a real phone number is real.

    The demo application will use Spring Boot and I will show how to use the Bean Validation framework to create a @ValidPhoneNumber annotation that can be used like you would @NotNull.

    Starting out

    What you will need before you start

    • A Twilio account. Sign up using this link and you can get an extra $10 …
    Read More
  • By Matthew Gilliard
    How to build a Conference line with Twilio and Java How to build a Conference line with Twilio and Java

    Another conference call, another app, another PIN, another log-in. Joining conference calls should be as easy as dialing a phone number, without the hassle of so many extra digits. This post will show how you can build a conference line that anyone and everyone can join, using Twilio with Java and Spring Boot.

    Java Development Environment Setup

    Start by making sure you have the right software installed that you'll need to use for the rest of this post. You will need:

    • Java - You’ll need at least Java 8. My preferred way to install it is using SDKMAN!
    • A free Twilio account and a Twilio phone number

    Starting out with Spring Boot

    You can use SDKMAN! to install the Spring Boot cli tool with sdk install springboot. Use this to create a new project in an empty directory with:

    spring init \
      --dependencies web \
      --build maven \
      --groupId …
    Read More
  • By Aaron Alaniz
    Implementa tu Propia Aplicación de Vídeo Conferencia en Menos de Cinco Minutos programmable-video-translate-conference

    Nos complace anunciar que hemos creado tres aplicaciones de vídeo conferencia en código abierto, una para iOS, otra para Android y una tercera en ReactJS para Web. Sea porque estás construyendo una solución de colaboración para salud, educación o en vídeo en general, estas aplicaciones pueden acelerar el desarrollo al proporcionar una base funcional implementada en la nube en minutos. Además, pueden actuar de referencia para todo desarrollador que quiera mostrar las posibilidades que tiene el video programable. Las aplicaciones están disponibles en Github bajo licencia Apache 2.0:

    Read More
  • By Aaron Alaniz
    Deploy your own video collaboration app in five minutes or less Deploy your own video collaboration app in 5 minutes or less

    Today we are excited to announce that we are open sourcing three video collaboration applications, one for iOS, one for Android, and a ReactJS one for the Web. Whether you are building a healthcare, education, or general video collaboration solution, these apps can accelerate development by providing you with a fully functioning video app that can be deployed to the cloud in minutes. In addition, they provide a canonical reference for developers building out their communication solutions by showcasing the Programmable Video capabilities. These applications are available today on Github under the Apache 2.0 license:

    At Twilio we strive to build a reliable, extensible platform so that our customers can build high quality communication experiences in their applications. Our Video SDKs provide the API building blocks for mobile and web developers to create custom communications experiences in their apps. We believe …

    Read More
  • By Matthew Gilliard
    Using SDKMAN! to work with multiple versions of Java Using SDKMAN! to work with multiple versions of Java

    If you code in Java, you might be coding against Java 11, or 8, or maybe an even older version. You may also be prototyping code against newer versions of Java, the current version is 13. Java 14 will be released this month, and 15 later this year. At the same time, you might be investigating different builds of OpenJDK - there are several free alternatives. I use AdoptOpenJDK’s builds of OpenJDK which is an increasingly popular choice according to the JVM Ecosystem Report 2020.

    You could also be trying out different build tools like Maven and Gradle. I use both, depending on the project.

    Put bluntly, managing all this can be difficult. It’s not impossible to manage by hand, but it’s fiddly and if you get it wrong the error messages can be hard to understand.

    Enter SDKMAN! It’s a tool for managing the installation and selection …

    Read More
  • By Pooja Srinath
    Send SMS in Your Spring Boot App spring-boot-java-websockets.png

    In this article, you’ll learn how to use WebSocket API with Spring Boot and build a simple status delivery application at the end.

    WebSocket is a communication protocol that makes it possible to establish a two-way communication channel between a server and its client. Websockets are supported by most of the browsers that are commonly used today. 

    Create an Application

    First, you need to set up your Twilio account and a suitable phone number.

    Here are the steps to generate a project using Spring Initializr: 

    1. Go to http://start.spring.io/.
    2. Enter Artifact’s value as websocket-callback.
    3. Add Websocket in the dependencies section.
    4. Click Generate Project to download the project.
    5. Extract the downloaded zip file.
    6. Note: You will need Java 8 or …
    Read More
  • By Matthew Gilliard
    How to Send Email in Java using Twilio SendGrid How to Send Email in Java using Twilio SendGrid

    If you’re writing a Java app and you need to programmatically send some emails, the Twilio SendGrid API is just the thing you need.

    You’ll need to sign up for a free Twilio SendGrid account and create an API key. Then you can get started with a few lines of code.

    In this post I’ll go through each step to get you up and emailing in no time.

    Starting Out

    You’ll need:

    The first thing you should do is to create a SendGrid account. The free tier will work just fine for this tutorial. Once you are signed up and logged in, create an API key. You can choose any name you like, but make sure to save the key before moving on.

    A screenshot of the "Create API Key" dialog on the SendGrid  console, showing 3 options, of which I have selected "Full Access" and called my key "my-api-key"

    Choose “Create & View” …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.