3

I am using twilio api for sending messages. Following is my script.

$AccountSid = "xxxxxxxxxxxxx";
$AuthToken = "xxxxxxxxxxxx";
$from = 'xxxxxxx';
$to = '+91xxxxxxxxxxxxx';

$uri = 'https://api.twilio.com/2010-04-01/Accounts/' .$AccountSid . '/SMS/Messages';
$auth = $AccountSid . ':' . $AuthToken;

$fields = '&To='.urlencode( $to ).'&From='.urlencode($from).'&Body='. urlencode('This is my test message');


$res = curl_init();
curl_setopt( $res, CURLOPT_URL, $uri );
curl_setopt( $res, CURLOPT_POST, 3 ); 
curl_setopt( $res, CURLOPT_POSTFIELDS, $fields );
curl_setopt( $res, CURLOPT_USERPWD, $auth ); 
curl_setopt( $res, CURLOPT_RETURNTRANSFER, true ); 
$result = curl_exec( $res );
return $result;

SMS are not coming to my mobile.

Is twilio works for indian mobile numbers?

3
  • @Ramya.twillo working for indian mobile numbers .you have add to +91 Commented Nov 2, 2016 at 8:35
  • I added +91 to my number Commented Nov 2, 2016 at 8:41
  • @Ramya.you can check Gowri answer because same think happend to me also.if your Twilio account is under trail mode then you will not receive sms Commented Nov 2, 2016 at 8:46

1 Answer 1

2

You script is correct. Yes, Twilio works for indian numbers.

Is your Twilio account is under trail mode. If it's in trail mode sms are not sent for non registered(Verified) mobile numbers. You have to register your mobile number in twilio service.

From twilio console verify your testing mobile number.

Use this url to https://www.twilio.com/console/phone-numbers/verified verify your mobile number.

After that verified mobile number will receive sms's.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, It's working I received sms after verifing 'to' number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.