使用字母數字發件人 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"
   }
}