Integrate Twilio SMS Service in a Website using PHP

Many people want to integrate Short Messaging Service into web applications to send notifications, promotions, reminders to their clients or members from their websites. This can be done using Twilio. Twilio is a cloud communications company that allows developers to programmatically send and receive text messages and make and receive phone calls using its web service APIs. Now we are going to learn how to setup and use Twilio for sending text messages to single/multiple recipients.

Simsple Twilio Text Messaging Application using PHP

In this project I have used The Twilio PHP Helper Library by Twilio. Let’s start with setting up Twilio account first.

Twilio Account Setup:

Step 1: Go for and Signup for a new Twilio account or Sign in if you already have one.

Step 2: To get started with Twilio you can sign up for a trial account at

Step 3: Verify your phone number as an outbound caller ID with Twilio. For information on how to verify your phone number, see For purposes of this example, use the verified phone number as text message recipient in this application.

Note: If you are using a trial account, then its compulsory to use only your own verified phone number for receiving text messages. As an alternative to using an existing number, you can purchase a Twilio phone number.

Step 4: Get account SID and Auth Token from which will be used in this application.

Get SID & Auth Code From TwilioStep 5: Get your Twilio account phone number from which will be used as sender in text messages.

Get Twilio Account number


PHP Code:

We will be working with config.php, example.php, integrate.php and functions.php. Proper understanding of these files is necessary.



This file has two functions. send_message function is used to send message to a single recipient. It has two parameters ($receiver and $message). $receiver contains number to which text message will be sent. $message is body of the message.

send_multiple_message function is used to send text messages to multiple recipients. It also has two parameters, the only difference is that $receiver has multiple recipients separated with a comma( , ).



This file can send message to a single recipient. HTML Form with $_POST method is used to send data.


If you want to send message without HTML Form use below code in any desired PHP file.

Download Twilio Text Messaging App With PHP - Earlysandwich Com
Download Twilio Text Messaging App With PHP - Earlysandwich Com
download Twilio text messaging app with PHP -
281.8 KiB

2 Replies to “Integrate Twilio SMS Service in a Website using PHP”

  1. api says:

     your tutorial, but there is a way to send msn freely? because I guess this is to pay for use the services!.
    Thanks for your excellent tutorials, I just see, to the website and is perfect !. 🙂

  2. api says:

    You can, make a tutorial with drag drop using html5 ajax or javascrit mysqli and
    two tables with two container and save automatic in database

    for example!. its just, for example!

    get data from table one, drag!, and save in the table two, drop!

    the table one, with this structure!. (table = students)

    the table two, with this structure!.

    now!, get data, from table students,
    and show, in container student, inside of tags ul,li for drag the items
    and, move the students to the container two for save in the database with ajax automatic for not lost the container of the groups.

    thanks, I hope see soon this tutorial. thanks for your time, and take my suggestion. for next tutorial. 🙂
    nice tutorials!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

scroll to top