Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created November 16, 2011 16:35
Show Gist options
  • Save RobSpectre/1370578 to your computer and use it in GitHub Desktop.
Save RobSpectre/1370578 to your computer and use it in GitHub Desktop.
Line break in a Twilio SMS using SimpleXML
<?php
$ACCOUNT_SID = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$AUTH_TOKEN = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
$TWILIO_NUMBER = "+1aaabbbcccc";
$TEST_NUMBER = "+1xxxyyyzzzz";
include 'Services/Twilio.php';
// Use SimpleXML to get the message body.
$xml = <<<XML
<root>
<element>This is a test with a linebreak.\n\n Totally.</element>
</root>
XML;
$simplexml_object = simplexml_load_string($xml);
// Send text message
$client = new Services_Twilio($ACCOUNT_SID, $AUTH_TOKEN);
$client->account->sms_messages->create(
$TWILIO_NUMBER,
$TEST_NUMBER,
trim($simplexml_object->element)
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment