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
    JavaでHTTPリクエストを作成する5つの方法 How to make HTTP requests in Java

    [ヘッダー画像クレジット: バタフライ星雲の鉄、NASA Astronomy Picture of the Day、2020年7月21日(修正版)]

    この記事はTwilio Developer EvangelistのMatthew Gilliardこちら(英語)て執筆した記事を日本語化したものてす。

    HTTPリクエストの作成はモダンプログラミングのコア機能であり、新しいプログラミング言語の習得時に最初に学習したい操作の1つです。Javaプログラマーがこの操作を実行する場合、JDKのコアライブラリやサードパーティライブラリなどさまざまな方法を使用できます。この記事では、Java HTTPクライアントを使用する方法について説明します。もちろん他の方法も使用できますので、情報をお寄せいただければ幸いです。この記事では、次の内容について説明します。

    Core Java:
    • HttpURLConnection
    • HttpClient
    よく使用されるライブラリ:
    • ApacheHttpClient
    • OkHttp
    • Retrofit

    ここではNASA APIAstronomy Picture of the Day APIをコードサンプルに使用します。このコードはすべて、GitHubのJava 11ベースのプロジェクトにあります。

    Java httpリクエストの作成に使用する主要なJava API

    Java 1.1以来、JDKに付属するコアライブラリにはHTTPクライアントが含まれています。Java 11では新しいクライアントが追加されました。プロジェクトに余分な依存関 …

    Read More
  • By Diane Phan
    How to Send a Message on WhatsApp With Java header - How to Send a Message on WhatsApp With Java

    The WhatsApp Business API from Twilio is a powerful, yet easy to use service that allows you to communicate with your users on the popular messaging app.

    With the help of Twilio and Java, you can deliver a quick message to someone over WhatsApp without having to pick up your mobile device.

    In this article, you'll be using your handy dandy command line and writing a couple of lines of Java code to send a WhatsApp message in an insanely fast manner. So why wait? Let's get started!

    screenshot of the WhatsApp message sent with Java

    Tutorial requirements

    • A free or paid Twilio account. If you are new to Twilio get your free account now! (If you sign up through this link, Twilio will give you $10 credit when you upgrade.)
    • Some prior knowledge of Java or a willingness to learn.
    • A smartphone with WhatsApp, to test the project.

    The Twilio WhatsApp sandbox

    Twilio provides a …

    Read More
  • By Matthew Gilliard
    Live transcription with Twilio Media Streams, Azure Cognitive Services and Java Live transcription with Twilio Media Streams, Azure Cognitive Services and Java

    Twilio Media Streams can be used to stream real-time audio data from a phone call to your server using WebSockets. Combined with a Speech-to-Text system this can be used to generate a real-time transcription of a phone call. In this post I’ll show how to set up a Java WebSocket server to handle audio data from Twilio Media Streams and use Azure Cognitive Services Speech for transcription.

    Requirements

    In order to follow along, you will need to have:

    If you want to skip ahead, you can find the completed code in my repo on GitHub.

    Getting Started

    To get a Java web …

    Read More
  • By Diane Phan
    How to Send an MMS with Java header - How to Send an MMS with Java

    Twilio is all about powering communication and doing it conveniently and fast in any language.  

    With the help of Twilio and Java, you can deliver a quick message to someone without having to pick up your mobile device.

    In this article, you'll be using your handy dandy command line and writing a couple of lines of Java code to send an MMS in an insanely fast manner. So why wait? Let's get started!

    Tutorial requirements

    • A free or paid Twilio account. If you are new to Twilio get your free account now! (If you sign up through this link, Twilio will give you $10 credit when you upgrade.)
    • Some prior knowledge of Java or a willingness to learn.
    • A smartphone with active service, to test the project

    Configuration

    We’ll start off by creating a directory to store the files of our project. Inside your favorite terminal, enter:

    $ …
    Read More
  • By Matthew Gilliard
    Making Voice Calls with Java and Twilio Title: Making Voice Calls with Java and Twilio

    The capability to make outbound calls from code has a long history at Twilio. It will only take you a few minutes to set up a Java project to do just that and see the magic for yourself. To follow along with this post you'll need:

    The easiest way to call the Twilio API is with the Java Helper Library. In this tutorial I'll give examples using the Apache Maven build …

    Read More
  • By Matthew Gilliard
    How to send SMS at scale with Twilio Title: How to send SMS at scale with Twilio

    If you want to send a single SMS using Twilio you'll need a Twilio account, a phone number to send them from, and of course you'll need to know the destination phone number and the content of the message. Once you have these you can send your message with a single API call either with a direct HTTP request, or using any of our helper libraries. Check out our Programmable SMS Quickstarts for more details.

    What if you need to send a hundred messages? Or a thousand? Or even more? In this post I'll talk through the challenges you may face as you scale up and how to get past them. Code samples will be in Java but the same principles apply with any programming language.

    Sending a single SMS

    Sending one SMS with Java is covered in this blog post. Feel free to go and read it, …

    Read More
  • By Liz Moy
    Build a Stock Quote WhatsApp Bot with Java and Twilio Build a Stock Quote WhatsApp Bot with Java and Twilio

    Photo courtesy of Pixabay (CC BY 2.0)

    Whether you are a seasoned investor, downloaded RobinHood when the r/wallstreetbets events overtook the news cycle, or are keen to play with a new API, you can never have too many methods of checking the latest stock prices. You will build a bot for WhatsApp that will message a user basic stock quote information when they send in a valid ticker symbol.

    You’ll use the Finnhub.io Stock API to do so. They also have a Forex and Crypto API, so check those out if you want to add on to what you will build here.

    Prerequisites

    • A Twilio Account - sign up for a free one here and get $10 when you upgrade your account
    • Java 8 or above (for simpler installation, check out SDKMAN! This tutorial uses version 11.0.10.hs-adpt.
    • API Key for the Finnhub.io API -  Register for a free …
    Read More
  • By Matthew Gilliard
    5 Maneiras de Fazer uma Chamada HTTP em Java 5 Maneiras de Fazer uma Chamada HTTP em Java

    Fazer chamadas HTTP é uma funcionalidade fundamental da programação moderna, e geralmente é uma das primeiras coisas que você vai querer fazer ao aprender uma linguagem de programação nova. Para programadores Java, existem diversas maneiras de se fazer isso - bibliotecas core na JDK e bibliotecas de terceiros. Este artigo vai te introduzir aos clientes HTTP Java que eu geralmente uso. Se você usa outros, ótimo! Me conte mais sobre eles. Veja o que vou cobrir neste artigo:

    Core Java:

    • HttpURLConnection
    • HttpClient

    Bibliotecas Populares:

    • ApacheHttpClient
    • OkHttp
    • Retrofit

    Eu vou usar a API de Imagem Astronômica do Dia das APIs da NASA para os código de exemplo, e o código está todo no GitHub em um projeto baseado em Java 11.

    APIs Core do Java para se fazer chamadas http no Java

    Desde o Java 1.1 já havia um cliente HTTP nas bibliotecas core com o JDK. Com o Java 11, …

    Read More
  • By Matthew Gilliard
    Sending SMS with Java with Twilio Title: Sending SMS with Java and Twilio

    Did you know you can code a Java app in under 5 minutes to send an SMS using the Twilio API? Probably closer to 2, once you've got the tools installed. You'll need:

    The easiest way to call the Twilio API is with the Twilio Java Helper Library. In this I'll give examples using the Apache Maven build tool which will download and manage the dependency and packaging the project. You can get up to speed with Maven in 5 Minutes, …

    Read More
  • By Matthew Gilliard
    Receiving and Responding to SMS with Java and Twilio Title: Receiving and Responding to SMS with Java and Twilio

    If you're wondering how to send SMS from Java code, we've got you covered already. However, people are increasingly expecting to be able to converse with companies and services rather than just get a never-ending stream of notifications. To build really engaging and interactive apps you're going to want to respond to incoming messages too.

    To do that, you will need to configure a URL in your Twilio console. Incoming messages will trigger HTTP requests to that URL, and the response to those webhook requests will determine what happens next, including sending responses. Responses should be written in an XML dialect called Twilio Markup Language, or TwiML.

    In this post I'll walk you through setting up a web server using Spring Boot to do just that.

    Getting set up

    Before we get started, you'll need:

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