Skip Navigation Links.
展开 最小化

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[] 联系人/订阅者的号码.
事务性MMS填写该参数值,否则为空。
必填
category String[] 目标联系人名单的名称.
营销性MMS填写该参数值,否则为空。
必填

参数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>