Reputation: 11
I'm a Twilio user and i tried to do a line break (with \n command) on the sms body form on the API explorer page but it doesn't work.
Here you can find a screenshot :
Thank you very much
Upvotes: 1
Views: 2893
Reputation: 10058
I tried the following code via PHP script and works fine, without escaping the new line.
<?php
require('/Users/user/Documents/Twilio/Development/PHP/libraries/twilio-php-master/Services/Twilio.php'); // This line loads the helper library
$sid = "XXXXXXXXX"; // Your Account SID from www.twilio.com/user/account
$token = "YYYYYYYY"; // Your Auth Token from www.twilio.com/user/account
$client = new Services_Twilio($sid, $token); // instance of the Twilio helper REST Client
$from = "+1 415-319-1111"; // a valid Twilio number
$to = "+1408-319-2222"; // your mobile number
$body = "Ahoy from Twilio!\n New line"; // sms message body
try {
$message = $client->account->messages->sendMessage( $from, $to, $body);
echo $message->sid; // Twilio's identifier for the new message
} catch (Services_Twilio_RestException $e) {
echo $e->getMessage(); // A message describing the REST error
}
?>
Upvotes: 1
Reputation: 73029
Twilio developer evangelist here.
This is probably a case of the API explorer escaping things for you. I just tried using the Ruby helper library and got an SMS message with a line break in it. Have you tried using the API itself?
Upvotes: 0