How can I include a url in an outgoing text message using twilio API? I tried, but the message was not sent. Is there a specific format? syntax?
Update: Here's the code: (I am using the php api) Perhaps the problem is with using a variable in the link? or maybe in a different format?
$sms = $client->account->sms_messages->create(
"xxx-xxx-xxxx",
$send_to_number,
"Hey $var1. words words $var2. via example.com.
see: https://graph.facebook.com/$fb_id/picture");
The example.com
link works perfect, so do $var1
and $var2
. But when adding the last link which includes a variable (and it is from facebook graph api, but I don't think that matters), then the message is not sent. Is there any way to solve this without url shortener?
SMS messages sent via Twilio are limited to 160 characters because carriers will break messages up into 160 character sized chunks. These chunks doen't necessarily arrive in order, so it is recommended to send some sort of pagination along with the message if you expect it to be over 160 chars.
https://www.twilio.com/help/faq/sms#sms-technical-3
The official Twilio PHP helper library will error out if you attempt to send a message longer than 160 characters.
Something else to watch out for: if you break your message into two lines like you have done here, PHP will include the characters you used for indentation in the message, so the above code will produce an SMS message that looks like this:
Hey $var1. words words $var2. via example.com.
see: https://graph.facebook.com/$fb_id/picture
The message is too long. There is a limit of characters in a twilio message. This has nothing to do with the variable. It now works, just shortened the text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With