使用字母数字发件人 ID 发送单个邮件

HTTP POST 请求将发送到以下格式的 URL:“ https://api.twilio.com/2xxx-xx-xx/Accounts/[AccountSid]/Messages.json

以下示例使用字母数字字符串作为发件人。在撰写本文时,只能通过服务请求 Twlio 添加发件人 ID。

示例请求:

To="+447111111111" ;
From="Wxxxxxxxxx" ;
MessagingServiceSid="MGxxxxxxxxxxxxxxxxxxxxxx" ;
Body="Test Message" ;
AccountSid="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ;
AuthToken="[Auth Token]" ;
CMD="curl --request POST \"https://api.twilio.com/2010-04-01/Accounts/${AccountSid?}/Messages.json\" " ;
CMD="${CMD?}--data-urlencode \"From=${From?}\" " ;
CMD="${CMD?}--data-urlencode \"To=${To?}\" " ;
CMD="${CMD?}--data-urlencode \"MessagingServiceSid=${MessagingServiceSid?}\" " ;
CMD="${CMD?}--data-urlencode \"Body=${Body?}\" " ;
CMD="${CMD?}-u \"${AccountSid?}:${AuthToken?}\"" ;
echo "${CMD?}" ;
eval "${CMD?}" ;

示例响应(JSON,格式化):

{  
   "sid":"SMxxxxxxxxxxxxx",
   "date_created":"Tue, 26 Jul 2016 12:50:07 +0000",
   "date_updated":"Tue, 26 Jul 2016 12:50:07 +0000",
   "date_sent":null,
   "account_sid":"ACxxxxxxxxxx",
   "to":"+447111111111",
   "from":"Wxxxxxxxxx",
   "messaging_service_sid":"MGxxxxxxxxxxx",
   "body":"Test Message",
   "status":"accepted",
   "num_segments":"0",
   "num_media":"0",
   "direction":"outbound-api",
   "api_version":"2010-04-01",
   "price":null,
   "price_unit":null,
   "error_code":null,
   "error_message":null,
   "uri":"/2010-04-01/Accounts/ACxxxxxxxxxxxx/Messages/SMxxxxxxxxxxx.json",
   "subresource_uris":{  
      "media":"/2010-04-01/Accounts/ACxxxxxxxxx/Messages/SMxxxxxxxxxxxx/Media.json"
   }
}