Send SMS with PHP and Twilio
It takes just a few lines of code and even fewer minutes to send your first text message with PHP and Twilio. Here’s how:
Sign up for a free Twilio account and buy a phone number.
Install the PHP helper library with Composer: composer require twilio/sdk:5.* then put require "vendor/autoload.php'; at the top of your file.
Create a file called send-sms.php and paste in the code below to:
- Include the helper library
- Create a Twilio client using our account credentials
- Create a new message from our Twilio number, to our cellphone
<?php require_once "vendor/autoload.php"; use Twilio\Rest\Client; $account_sid = "YOUR_TWILIO_ACCOUNT_SID"; $auth_token = "YOUR_TWILIO_AUTH_TOKEN"; $twilio_phone_number = "YOUR_TWILIO_PHONE_NUMBER"; $client = new Client($account_sid, $auth_token); $client->messages->create( 'DESTINATION_PHONE_NUMBER', array( "from" => $twilio_phone_number ...
Set Up a Temporary Phone Number in 3 Minutes with Twilio
If you’ve ever sold anything on Craigslist, requested a quote on the internet, or watched The Wire, then you may have found yourself wishing for a “burner” phone. In this post we’ll use TwiML Bins to create a temporary phone number that forwards phone calls to your cellphone. This will take less than three minutes, even if you’ve never written a line of code before!
Sign up for a free Twilio account if you don’t already have one. Then go to Developer Tools in your console and click on TwiML Bins. TwiML is a simple set of instructions used to program your Twilio number. TwiML Bins let you host static TwiML without setting up a server of your own.
Create a TwiML Bin. Name it “Forward to my cellphone.” Then copy this code to
your cellphone number when a call comes in.
<Response> < ...
How to Text with Hodor
Hodor is not man of many words. In fact, he’s just got one: “Hodor.” And while communication may not be his forte, one wonders how his adventures with Brandon Stark might have turned out if they had the mobile communication technology we all take for granted today.
Thanks to the recent release of TwiML Bins we don’t have to wonder any longer. To get in contact with Hodor, you need only call or text our Hodor Hotline at (917) 722-6264. Ask him anything you like, and digest the wisdom of his reply.
Even if you’ve never written a line of code before, you can build a hotline like this yourself in just five minutes with TwiML Bins. It’s easier than falling out the moon door. You’ll need to sign up for a free Twilio account to get started. Then there’s just three steps:
- Write ...
Twilio Radio – The Podcast by Twilio
Twilio Radio is a podcast featuring interviews from a few of the 100 speakers presenting at SIGNAL, our developer conference for communications. You can find Twilio Radio in iTunes and other podcast directories or you can listen to the interviews below. And if you’d like to join us at SIGNAL, use the promocode RADIO for 20% off when you register.
Where do text messages come from?
Ben Stein, who runs the messaging team at Twilio, talks about:
- Why SMS is such an effective communication medium for businesses
- SMS open and response rates
- The SMPP (SMS) protocol
- Technical differences between SMS and MMS
- Best practices for scaling a Twilio messaging app
What developers should know about job searching and negotiation
Patrick McKenzie, co-founder of StarFighters, talks about:
- What’s broken about with the recruiting and interviewing process?
- How should a developer start their job search?
- How should a developer answer ...
How to Receive and Reply to an SMS in Rails with Twilio
Many thanks to James Jelinek (@shakycode) for this guest post on how to receive and reply to text messages with Rails.
I’ve been working with Rails (and Twilio) for several years now and I love it. Twilio makes SMS, MMS, and Voice so easy to use. Even with the ease of use there is still somewhat of a learning curve as it pertains to integrating Twilio into your Ruby on Rails app. Today we’re going to cover a simple integration of Twilio into a new Ruby on Rails application that handles inbound and outbound messages. The first thing we need to do is to create a new Rails app.
rails new sms
This will generate our app simply called, “SMS”. Now we need to generate a basic controller to act as our endpoint for Twilio’s inbound requests.
rails g controller messages reply
When we create the controller ...!-->
Where Do Text Messages Come From?
“…and when you click “SEND”, the API Stork scoops up your text message in its beak and flies a great distance to drop the message off to your recipient.”
That doesn’t seem accurate. To get to the bottom of where texts come from we talked to Ben Stein, who is the man leading the messaging team here at Twilio. He sorted out the stork debate.
Listen to our interview with Ben Stein below
or find the Twilio Radio podcast on iTunes.
Why are you such a fan of SMS?
There’s so many things that point to SMS as not being a great way to communicate, but it turned out to be the most popular form of communication on the planet. It’s the only app that’s installed on every single phone ever. Email is not installed on every phone, but SMS is.
And there’s something about ...
3 SIGNAL Speakers to Get You Started with the Internet of Things
Tired of watching your Arduino collect dust on your desk? We’ve got three rad speakers queued up at SIGNAL to get you started with hardware hacking and the Internet of Things.
Katy Moe Live Codes her Hand
Kristin Salomon talks Hardware Hacking for Software People
If want to get started in hardware hacking but have no experience with electronics and soldering, this session is for you. littleBits are electronic building blocks that snap together magnetically and can connect to the Internet via WiFi. Kristin Salomon is an Electronics Engineer at littleBits and gave such a great talk ...
Sara Chipps on Teaching Girls to Code with Wearables
Sara Chipps has spent the better part of a decade teaching women to code. Her latest startup, JewelBots, makes programmable friendship bracelets for young girls get get them excited about engineering before their social circles tell them its uncool. She down with us on Twilio Radio to talk about user testing with middle school girls, why the hardware hacking world seems to be more diverse than the programming world, and how men can appropriately get involved with helping women and girls learn to code.
Below is a partial transcript of our conversation with Sara. It’s been edited for the sake of narrative, which is to say that she said all these things but not necessary in this order. You can listen to the podcast for the full interview.
Sara’s one of the 100 speakers speaking at SIGNAL, our developer conference for communications. If you’d like to meet ...
How To Validate and Look Up Phone Numbers in Google Spreadsheets
In ten minutes, you can teach your spreadsheet some new tricks, even if you’ve never written a line of code. We’ll use Google Spreadsheet and Twilio Phone Number Lookup API to validate, clean up and format phone numbers easily.
The Twilio Lookup API can be used to:
- Tell if phone number a cellphone or landline.
- Tell if a phone number is real or fake
- Clean up incorrectly formatted phone numbers
- Properly format a list of phone numbers
The Twilio Bits
If you don’t have a Twilio account, sign up here. A free trial account gives you $20 in Twilio credit to play with. At $0.005 per lookup, you can look up 4,000 phone numbers before upgrading your account.
Once you’re signed-in, go to your dashboard and click Show API Credentials. Keep your credentials handy — we’ll be pasting them into our code in a ...
How to Send SMS from a Google Spreadsheet
You may also be interested in How to Clean Up and Validate Phone Numbers in a Google Spreadsheet. With that tutorial, you can figure out which phone numbers in your spreadsheet can receive a text message before trying to send it.
The Twilio Bits
You’ll need a free Twilio account. If you don’t have one, sign up for an account here. You can do everything in this tutorial with a trial account, though you’ll be restricted to sending text messages to only your cellphone. (If you upgrade your account, $20 buys you about 2,500 text messages in ...