SpreadWebServcie.SendMMS Method

發送事務性/營銷性MMS。它創建一個MMS活動。

參數

參數 類型 描述 事務性 營銷性
loginEmail String Spread賬號的登錄電郵 必填 必填
apiKey String Spread賬號的API Key(參見:如何從Spread平臺獲取API賬號信息 必填 必填
subject String MMS的標題 必填 必填
mmsContent String MMS的內容 必填 必填
imageBase64String Base64String MMS的圖像,格式是base64 string。 選填 選填
sender String MMS的發送者.
保持此參數為空,除非你的賬號配置了發送者。
選填 選填
schedule DateTime MMS活動的計劃發送時間。過去的時間會立刻發送。
格式:yyyy-MM-ddTHH:mm:ss,時區:UTC +08:00。
營銷MMS會按照此時間發送,事務MMS會立刻發送。
必填 必填
campaignStatus CampaignStatus MMS活動的狀態。(用於營銷型MMS,Waiting或者Draft) 必填 必填
phoneSubscribers String[] 聯絡人/訂閱者的號碼.
事務SMS請填寫此參數值,否則爲空。
必填
category String[] 目標聯絡人名單的名稱.
營銷SMS請填入此參數值,否則為空。
必填

參數phoneSubscriberscategory只填寫其中一個,另一個留空。

返回結果

IntegerException。如果成功,則返回 campaign Id(大於0的數字),否則返回異常(Exception)或者小於等於0的數字。

請在下列表格中找到詳細的返回信息:

HTTP狀態碼 返回信息 狀態/場景
200 Campaign Id,這個值是數字且大於0。 成功發送MMS 或 成功創建 MMS 活動。
200 返回小於等於0的數字。 發送MMS失敗。
500 Parameters loginEmail, apiKey, subject and mmsContent cannot be empty! 參數loginEmail, apiKey, subject或者mmsContent 一個或以上為空,請填寫所有必填參數。
500 Parameters phoneSubscribers and category cannot all be empty! 填寫參數phoneSubscriberscategory的其中一個。
500 Spreader Email and Password not match! 請檢查參數loginEmailapiKey是否填寫錯誤,無誤後檢查請求的接口連結(常見問題
500 This user has expired! 使用的賬號過期了,請激活。
500 Error Sender! xxxx 保持此參數為空,除非你的賬號配置了sender。或者,賬號設置的sender不包含xxxx,請修改成正確的sender。
500 Please contact us at spread@reasonables.com to get SMS service. 該賬號未設置MMS服務,請聯絡管理員進行設置。
500 Invalid phone number 00000 in phoneSubscribers! 參數phoneSubscribers的值00000驗證失敗
500 Spread MMS only supports 852 and 853 MMS服務只暫時支持區號為852和853的手機號碼
500 No MMS message credit! 該賬號沒有MMS的發送量,需充值再使用。
500 Image Upload to Access You Failed! 上傳圖片失敗
500 Create MMS campaign fail! failInformation
500 The service comes error! 其他錯誤情況,請聯絡技術人員。
500 拋出一個異常含有錯誤信息。 其他錯誤情況,比如超時。

例子

string loginEmail = "Spread@reasonables.com";
string apiKey = "TEST0000-TEST-0000-TEST-0000TEST0000";
string subject = "Test MMS 6";
string mmsContent = "Test MMS 6";
string imageLocalPath = @"D:\Documents\test.png";
string imgBase64String = Convert.ToBase64String(System.IO.File.ReadAllBytes(imageLocalPath));
string imageBase64String = System.Web.HttpUtility.UrlEncode(imgBase64String);
string sender = "";
string[] phoneSubscribers = new string[] { "85212341234", "85298769876" };
string[] category = { "" };
string campaingId = spreadAPI.SendMMS(loginEmail, apiKey, subject, mmsContent, imageBase64String, sender, DateTime.Now, CampaignStatus.Waiting, phoneSubscribers, category);
Dim loginEmail As String = "Spread@reasonables.com"
Dim apiKey As String = "TEST0000-TEST-0000-TEST-0000TEST0000"
Dim subject As String = "Test MMS 6" 
Dim mmsContent As String = "Test MMS 6" 
Dim imgBase64String As String = Convert.ToBase64String(IO.File.ReadAllBytes(imageLocalPath))
Dim imageBase64String As String = System.Web.HttpUtility.UrlEncode(imgBase64String) 
Dim sender As String = "Spread" 
Dim schedule As String = "2022-06-15T14:50:50" 
Dim campaignStatus As String = "Waiting" 
Dim phoneSubscribers As String() = { "85212341234" } 
Dim category As String() = {""} 
Dim postData As String = "loginEmail=" & loginEmail 
postData &= "&apiKey=" & apiKey 
postData &= "&subject=" & subject 
postData &= "&mmsContent=" & mmsContent 
postData &= "&imageBase64String=" & imageBase64String 
postData &= "&sender=" & sender 
postData &= "&schedule=" & schedule 
postData &= "&campaignStatus=" & campaignStatus 

For Each phone In phoneSubscribers 
    postData &= "&phoneSubscribers=" & phone 
Next 

For Each c In category 
    postData &= "&category=" & c 
Next 

Dim webRequest As WebRequest = WebRequest.Create("{{YOUR_API_URL}}/SendMMS") 
webRequest.ContentType = "application/x-www-form-urlencoded" 
webRequest.Method = "POST" 
Dim bytes() As Byte = Encoding.UTF8.GetBytes(postData) 
Dim os As Stream = Nothing 
webRequest.ContentLength = bytes.Length 
os = webRequest.GetRequestStream() 
os.Write(bytes, 0, bytes.Length) 
os.Close() 

Dim webResponse As WebResponse 
webResponse = webRequest.GetResponse() 
Dim sr As StreamReader = New StreamReader(webResponse.GetResponseStream()) 
Return sr.ReadToEnd().Trim()
No sample for PHP.
POST {{YOUR_API_URL}}/service.asmx 

Content-Type: application/soap+xml; charset=utf-8
Content-Length: {{length}}

<!-- Send Transactional MMS HTTP Body -->
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SendMMS xmlns="http://service.reasonablespread.com/">
      <loginEmail>Spread@reasonables.com</loginEmail>
      <apiKey>TEST0000-TEST-0000-TEST-0000TEST0000</apiKey>
      <subject>Test</subject>
      <mmsContent>Test</mmsContent>
      <imageBase64String>iVBORw0KGgoAAAANSUhEUgAA</imageBase64String>
      <sender></sender>
      <schedule>2022-12-20T14:50:50</schedule>
      <campaignStatus>Waiting</campaignStatus>
      <phoneSubscribers>
        <string>85212345678</string>
        <string>85212345679</string>
      </phoneSubscribers>
      <category></category>
    </SendMMS>
  </soap12:Body>
</soap12:Envelope>

<!-- Send Promotional SMS HTTP Body -->
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SendMMS xmlns="http://service.reasonablespread.com/">
      <loginEmail>Spread@reasonables.com</loginEmail>
      <apiKey>TEST0000-TEST-0000-TEST-0000TEST0000</apiKey>
      <subject>Test</subject>
      <mmsContent>Test</mmsContent>
      <imageBase64String>iVBORw0KGgoAAAANSUhEUgAA</imageBase64String>
      <sender></sender>
      <schedule>2022-12-20T14:50:50</schedule>
      <campaignStatus>Waiting</campaignStatus>
      <phoneSubscribers></phoneSubscribers>
      <category>
          <string>subscriptionName</string>
          <string>contactListName</string>
      </category>
    </SendMMS>
  </soap12:Body>
</soap12:Envelope>