Send Formatted messages through Twilio

吃可爱长大的小学妹 提交于 2020-02-04 08:44:25

问题


I want to know that how I can send formated messages through twilio .net api

Using .net library

So my requirements are like. also can I make use of html tags?

TwilioRestClient client;
            client = new TwilioRestClient(accountSID, authToken);
            string msg="Hi dalvir,
//line break

Welcome to my website.....
....


//line break

Thanks
<b>Support Team<b>


";
            // Send an SMS message.
            Message result = client.SendMessage(....);

回答1:


Use %0a

For example:

"Body=Here is my first line%0aHere is my second line"

When sending outbound messages via the REST API without using a helper library, it is best to encode a new line character using URL encoding. In URL encoding, a new line character is encoded as %0a.

Here’s an example cURL script:

curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
-d "To=+13105551234" \
-d "From=+12125555555" \
-d "Body=Here is my first line%0aHere is my second line" \
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token' 

This example sends an outbound message from the sender (212) 555-1234 (+12125551234) to the recipient at (310) 555-5555 (+13105555555), and includes the following message:

Here is my first line
Here is my second line




回答2:


Twilio developer evangelist here.

You can absolutely add line breaks in SMS messages. You can do so in the way you would normally include line breaks within .NET.

SMS messages do not support HTML tags though, so making text bold is not possible.



来源:https://stackoverflow.com/questions/31474599/send-formatted-messages-through-twilio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!