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
  • By Matthew Setter
    Build a PHP Phone Number Validator Using Twilio and laminas-validator Build a PHP Phone Number Validator Using Twilio and laminas-validator

    No matter where your data comes from — a user, database, an environment variable, or somewhere else entirely — it must be validated. If not, how can you be sure that it's valid?

    This is such an important and accepted part of modern software development that all of the major PHP frameworks, such as Laravel, Symfony, and Mezzio provide a validation component. If you're not using a framework, Composer can quickly integrate a third-party library such as laminas-validator.

    However, what if a validation library or a framework's validation component doesn't support a validator that matches your use case? In that case, it's time to write a custom validator.

    In this tutorial, I'm going to show you how to write a custom phone number validator for laminas-validator using Twilio's Lookup API.

    Tutorial Requirements

    To follow this tutorial you need the following components:

    Read More
  • By Matthew Setter
    Build a Phone Number Validator with Laravel Build a Phone Number Validator with Laravel

    Data validation is essential to any application, regardless of its size and purpose. Without it, you risk using data that's forged by malicious actors, contains only junk—or is a combination of both. And it doesn't matter where the data comes from either; whether from a web form, retrieved from a database, or read from an environment setting.

    Gladly, validation is extremely common in modern software development, so much so that there are numerous third-party packages available on Packagist, and PHP's major frameworks all have a validation component. With them, you can validate email addresses, passwords, dates, IP addresses, numbers and so much more!

    However, what happens when the package or framework doesn't support your use case, such as validating a phone number? In that case, you roll your own!

    In this tutorial, we're going to build a custom Laravel validation rule object that validates a phone number from any country …

    Read More
  • By Matthew Setter
    How to Lookup Phone Numbers in Plain PHP With Twilio's Lookup API How to Lookup Phone Numbers in Plain PHP With Twilio's Lookup API

    Phone numbers are a very common part of user profiles in modern applications. For example, they let users receive an OTP (One Time Password) to log in to an account or receive a recovery code when they can't access their second-factor device, and they let support staff contact a customer when there is suspicious activity on their account.

    However, how often do we check that the phone number which users store in their profiles is genuine? Today, I'm going to show you how to do it in plain PHP using Twilio's Lookup APIno framework required!

    Tutorial requirements

    To follow this tutorial you'll need three things:

    Create the project directory and install the …

    Read More
  • By Matthew Setter
    Build a WhatsApp Chatbot with PHP, Mezzio, and Twilio Build a WhatsApp Chatbot with PHP, Mezzio, and Twilio

    A chatbot is a software application that a person can have a conversation with, either in written or spoken form. That said, their capacity to have a conversation often varies greatly. For example, some chatbots can only answer quite a limited set of specific questions (sometimes in a fixed order). Others, however, use a combination of artificial intelligence (AI) and machine learning (ML) to interact almost as a human could.

    In this tutorial, I'm going to show you how to build a small, simplistic chatbot using the Twilio API for WhatsApp, the Mezzio framework for PHP, and the Weather API to retrieve the current weather forecast for any city around the world.

    How will the chatbot work?

    Before we dive in and write code, let’s get a quick overview of how the chatbot will work. In essence, here’s the logic of the project:

    1. A user will send a …
    Read More
  • By Matthew Setter
    How to Send an SMS in 30 Seconds with Ruby How to Send an SMS in 30 Seconds with Ruby

    Twilio is all about powering communication, regardless of the language—or language framework—that you're using for a given project.

    In this tutorial, you'll learn how to send an SMS directly from a Ruby application. What's more, you're going to use Twilio's Ruby Helper Library to make sending an SMS even faster than it would otherwise be. Ready to go? Let's dive in!

    Tutorial requirements

    To complete the tutorial, you will need the following things:

    • A free Twilio account (sign up with this link and get $10 in free credit when you upgrade your account)
    • Ruby, version 2.7 or later. If you don't already have Ruby installed, you can install it using your operating system's package manager (if you're using Linux or macOS) or download it.
    • Bundler
    • A smartphone with active service, to test the project.
    • The Twilio CLI (optional)

    Get your Twilio phone number

    As we're sending an SMS, …

    Read More
  • By Matthew Setter
    5 Ways to Make HTTP Requests in PHP 5 ways to make HTTP requests in PHP

    HTTP requests are a hallmark of modern, web-based applications—especially in PHP. We have to interact with all manner of APIs and external services, such as Google Cloud, Facebook, and AWS, on almost a daily basis. I’d go so far as to say that it might well be one of the first things that you learn after you’ve mastered PHP’s foundations. It was for me.

    That said, like many modern software development languages, there’s more than one way to make HTTP requests. So in this post, I’m going to introduce you to five of the most common options for making them in PHP. I’ll show how to use them and cover some of their respective strengths and weaknesses. I won’t explore them in intimate detail, rather give a broad introduction to each one.

    The approaches that I’ll cover are:

    Read More
  • By Matthew Setter
    How to Create a Landing Page with Laravel, Vue.js, and SendGrid How to Create a Landing Page with Laravel, Vue.js, and SendGrid

    Landing pages are everywhere in modern business.

    They're used when people offer a free giveaway in return for someone joining a mailing list, to sell a product or service, and as glorified resumes.

    Landing pages are a great solution for these kinds of business needs as they can be rapidly created and deployed. Knowing how to create them can also be a great skill for developers to have, whether creating landing pages for others or for personal projects.

    In this tutorial, I'll show you how to create a landing page using a combination of Laravel 8, Vue.js, and SendGrid. It's a reasonably long tutorial. By the end of it, I'm confident that you'll have learned a lot.

    Prerequisites

    To complete the tutorial, you will need the following 4 things in your local development environment:

    Read More
  • By Matthew Setter
    SMS mit Twilio versenden SMS mit Twilio versenden

    SMS ist eine einfache und etablierte Technologie mit der Unternehmen mit Ihren Kunden kommunizieren. Weltweit gibt es rund 7,2 Milliarden Mobiltelefone die SMS empfangen können, damit ist es sicherlich eine der verbreitetsten Technologien unserer Zeit.

    Im nachfolgenden Artikel wollen wir eine SMS aus einer einfachen Applikation über die Twilio API versenden. Die Integration ist einfach und mit jeder Programmiersprache möglich, in diesem Beispiel wollen wir die Twilio API mit PHP ansprechen.

    Vorbereitung

    Für die nächsten Schritte benötigen wir die folgende vier Dinge:

    Abhängige Pakete Installieren und Composer Konfigurieren

    Bevor wir den eigentlichen PHP Code schreiben, müssen wir die abhängige Pakete installieren und Composer konfigurieren. Dafür benötigen wir nur zwei Pakete, zum einen das Twilio Client SDK, also die Schnittstelle zu Twilio. Das zweite Paket ist PHP dotenv, mit diesem Paket werden wir die nötigen Umgebungsvariablen konfigurieren.

    Zum Installieren der zwei Pakete …

    Read More
  • By Matthew Setter
    How to Reply to an SMS with PHP’s Mezzio Framework

    In my previous tutorial on how to send an SMS with PHP’s Mezzio framework, we covered sending a text message in PHP. In this tutorial, we’ll expand on the application that we built so that it can also reply to an SMS when it is received.

    Prerequisites

    To follow along with this tutorial you should have the following:

    To get started, clone version 1.0.0 of the repository that we created in the previous tutorial. Alternatively, follow the previous tutorial to create what we achieved.

    Note: If you cloned the repository, make sure that you add your Twilio Account SID, Auth Token, and phone number to the .env file in the root directory of the project. You will also need to run composer install to install existing dependencies for the project.

    Regardless of the approach that …

    Read More
  • By Matthew Setter
    How to Send an SMS with Mezzio PHP Framework How to Send an SMS with Mezzio PHP Framework

    Whether we’re voting for our favorite candidate on shows such as X Factor, or receiving two-factor authentication codes to log in to services like MailChimp and GitLab, SMS are virtually ubiquitous in modern life. Not only do they make communication in life and work much easier, it also doesn’t take a lot of code to send them either.

    In this tutorial, you’ll learn how to create a simplistic API that can send an SMS using PHP’s Mezzio framework and Twilio’s PHP SDK.

    Once completed, you will be able to send a POST request to the API’s default endpoint, supplying the phone number to send the message to, and the message to send. If the message was successfully sent, then a JSON response will be returned showing a number of details about the sent SMS. If the SMS was not able to be sent, then an appropriate JSON response will …

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