通过Twilio发送格式化的消息 [英] Send Formatted messages through Twilio
问题描述
我想知道如何通过twilio .net api发送格式化的消息
I want to know that how I can send formated messages through twilio .net api
使用 .net库
所以我的要求就像.还可以使用html标签吗?
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(....);
推荐答案
使用%0a
例如:
"Body=Here is my first line%0aHere is my second line"
在不使用帮助程序库的情况下通过REST API发送出站消息时,最好使用URL编码对换行符进行编码.在URL编码中,换行符被编码为%0a .
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.
这是一个示例cURL脚本:
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'
此示例将发件人消息从发件人(212)555-1234(+12125551234)发送到收件人(310)555-5555(+13105555555),并且包含以下消息:
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
这篇关于通过Twilio发送格式化的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!