12

I have implemented test twilio sms application. I have downloaded three files from https://github.com/benedmunds/CodeIgniter-Twilio

I have used my account_sid, auth_token in twilio.php file which is in config folder. I have also used 'from' number as +15005550006 in that file.

I have used following codes in my controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Twiliosms extends TL_Controller {

function __construct()
{
    parent::__construct();
}
function index()
{
    $this->load->library('twilio');

    $from = '+15005550006';
    $to = '+91xxxxxxxxxx';
    $message = 'This is a test...';

    $response = $this->twilio->sms($from, $to, $message);
    //echo "<pre>";print_r($response);echo "</pre>";

    if($response->IsError)
        echo 'Error: ' . $response->ErrorMessage;
    else
        //echo 'Sent message to ' . $to;
        echo 'Sent message';
}
}

Now when I run the controller file in the browser(not in my machine but in server), it runs successfully and it shows "Sent message".

But no sms is received. Please help.

user2346003
  • 177
  • 2
  • 3
  • 9
  • I tried indian number and its returning "number is not a valid, SMS-capable inbound phone number or short code for your account" Seems like you need to go for paid account, buy number for 1$ – Max Apr 17 '15 at 06:29

3 Answers3

21

My name is Jarod and I work at Twilio. There are multiple reasons this could be failing so lets walk through them one at a time.

1. Sending an sms using Twilio test credentials will not result in an sms being sent.

Test credentials are used for testing and debugging your application. They are "fake" numbers, that do not send any data via carrier, but instead return preset error codes and responses in order to test response-handling in your application. As you experienced this specific test credential +15005550006 will always return NO ERROR, whereas +15005550001 will always respond with "This phone number is invalid".

2. You can only send SMS from a Twilio number or a verified phone number.

You can always send an SMS from a number you bought on Twilio.com, but in order to send an SMS from any other number you must first verify that phone number with Twilio. Read more about the difference here.


These are the most common reasons for not receiving and actual SMS but in the case of the Indian phone numbers it could very well be one of these rare limitations.

If none of these work we probably need to look into your specific account to find out what's happening, in which case you should reach out to support@twilio.com.

Hope this helps.

Jarod Reyes
  • 646
  • 6
  • 6
  • 4
    The link you posted flatly contradicts your statement about sending an SMS from a verified number: "A verified phone number is one that you can use as your Caller ID when making outbound calls with Twilio...A verified phone number cannot be used to send Twilio SMS messages." – sixty4bit Aug 07 '14 at 20:38
5

I banged my head against the walls for three hours and tried to work out with the number Twilio gave me at the time of sign up . But It always gave me the following error

{ "code": 21212, "message": "The 'From' number +234234234 is not a valid phone number or shortcode.", "more_info": "https://www.twilio.com/docs/errors/21212", "status": 400 }

At the end i got the exact point from where I got my test phone number for sms / call

Get your test phone number from Here .

Mani
  • 2,391
  • 5
  • 37
  • 81
2

You will have to make the from number a number you have verified with Twilio that you own: you can't just pick any number and use it. Do you own +15005550006, and have you verified that number in the Twilio admin console?

Femi
  • 64,273
  • 8
  • 118
  • 148
  • 2
    I have used verified number now and i got this message: Error: The From phone number provided is not a valid, SMS-capable inbound phone number or short code for your account. – user2346003 May 23 '13 at 06:51
  • That error message says that Twilio doesn't recognize the number you're using to send as a verified number. You should check that you're using the correct number, and also it sounds like you're trying to send international SMS (i.e. from a US number to an India number). I'm guessing the rules may be different for those if you're not using a fully paid account. – Femi May 23 '13 at 07:18
  • The phone number + 15005550006 is a magic (from) number from Twilio, that always passes validation for a developer when testing. As per Twilio's official docs https://www.twilio.com/docs/api/rest/test-credentials – heading_to_tahiti Jul 16 '15 at 18:25
  • @heading_to_tahiti, but I get 'The From phone number +15005550006 is not a valid, SMS-capable inbound phone number or short code for your account' with such number.... – Oleg Sh Feb 17 '16 at 21:39