一、配置文件app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MMSsend.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<MMSsend.Properties.Settings>
<setting name="MMSsend_MmsSend_WebService" serializeAs="String">
<value>http://sdk3.entinfo.cn:8060/webservice.asmx</value>
</setting>
</MMSsend.Properties.Settings>
</applicationSettings>
</configuration>
二、群发彩信WebServices(部分代码)
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.1
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
//
// 此源代码是由 Microsoft.VSDesigner 4.0.30319.1 版自动生成。
//
#pragma warning disable 1591
namespace MMSsend.MmsSend {
using System;
using System.Web.Services;
using System.Diagnostics;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Xml.Serialization;
/// < remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.0.30319.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="WebServiceSoap", Namespace="http://tempuri.org/")]
.......
.......
/// < remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/mdMmsSend", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string mdMmsSend(string sn, string pwd, string title, string mobile, string content, string stime) {
object[] results = this.Invoke("mdMmsSend", new object[] {
sn,
pwd,
title,
mobile,
content,
stime});
return ((string)(results[0]));
}
三、C#调用实现
参数名称 | 说明 | 是否必须 | 备注 |
Sn | 软件序列号 | 是 | 格式XXX-XXX-XXX-XXXXX |
Pwd | 密码 | 是 | md5(sn+password) 32位大写密文 |
title | 彩信主题 | 是 | 限制在30字符以内 |
Mobile | 手机号 | 是 | 手机号码多个以英文逗号隔开 |
Content | 内容 | 是 | base64编码(文件名1,文件base64编码串;文件名2,文件base64编码串);实际发送文件小于等于50*1024 字节 |
stime | 定时时间 | 否 | 例如:2010-12-29 16:27:03(非定时置空) |
函数返回值:String。
content是您发送的彩信的内容:包含图片和声音及文本;
1.文件类型: 文本是.txt 图片是.jpg或者.gif 声音是.mid或者.amr
2.内容格式:
帧数_文件类型.扩展名 + 英文逗号 + 文件的base64编码字符串 + 分号 ;
例如:“1_1.txt,” + 文件base64编码字符串 + “;” + “1_2.jpg,” + 文件base64编码字符串+”;”+”1_3.mid”+文件base64编码字符串
文本是 n_1.txt 图片是 n_2.jpg 或者是 n_2.gif 声音是 n_3.mid ;
N表示当前第几帧,后缀不变,编码均为GB2312。
接口地址:http://sdk3.entinfo.cn:8060/webservice.asmx?op=mdMmsSend
示例1
SN= SDK-SSD-010-00001
PWD=3B5D3C427365F40C1D27682D78BB31E0
title:彩信测试
Mobile:139***404,138***213…………….
Content:测试
Stime: ""
输出结果:
XML格式:
具体函数C#实现:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Web.Security;
namespace MMSsend
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//用于提交彩信
MmsSend.WebService mms = new MMSsend.MmsSend.WebService();
//该Demo很简单,只提交一帧,一帧里只有一种元素。
//byte[] byte2 = System.Text.Encoding.Default.GetBytes("彩信文字测试");
// string content = "1_1.txt," + Convert.ToBase64String(byte2) + ";";
//以上2句话是将字符串转换成base64字符串
string extension;
private void selectFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "所有文件|*.*";
ofd.Multiselect = true;
ofd.ShowDialog();
if (ofd.FileName!="")
{
path.Text = ofd.FileName;
}
int k = path.Text.IndexOf('.');
extension = path.Text.Substring(k + 1);
extension = extension.ToLower();
}
private void btn_send_Click(object sender, EventArgs e)
{
//序列号密码
string sn = "SDK-SSD-010-xxxxx";
string password = "XXXXXX";
//这里的密码是序列号和密码的MD5码
string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(sn + password, "md5");
//读取文件流
FileStream fs = new FileStream(path.Text, FileMode.Open);
byte[] sendbyte = new byte[fs.Length];
fs.Read(sendbyte, 0, sendbyte.Length);
fs.Close();
if (extension == "txt")
{
string content = "1_1.txt," + Convert.ToBase64String(sendbyte);
label1.Text = mms.mdMmsSend(sn, pwd, "新彩信接口c# demo测试", "18636800125", content, "");//换成您自己的手机号
}
else {
string content = "1_2." + extension + "," + Convert.ToBase64String(sendbyte);
label1.Text = mms.mdMmsSend(sn, pwd, "新彩信接口c# demo测试", "18636924700", content, "");//换成您自己的手机号
}
}
}
}
四、webservice返回集合对照表:
返回值 | 返回值说明 |
1 | 没有数据需要接收 |
-2 | 帐号/密码不正确 |
-3 | 重复登陆 |
-4 | 余额不足 |
-5 | 数据格式错误 |
-6 | 参数有误 |
-8 | 流量控制错误 |
-11 | 数据库错误 |
-12 | 序列号状态错误 |
-13 | 没有提交增值内容 |
-14 | 服务器写文件失败 |
-17 | 该接口禁止使用该方法 |
-18 | 等上一批提交结果返回再继续下一批提交 |
-15 | 内容长度长 |
-22 | Ip绑定 |
五、附加说明:
1.彩信语音SDK地址:
常用接口地址:http://sdk3.entinfo.cn:8060/webservice.asmx
2.其它说明:
(1)开发使用的帐号必须为SDK开头,如SDK-SSD-010-00001,帐号第一次需要调用Register方法注册一次.仅需注册一次即可,信息必须真实
(2)UnRegister与Register配合使用, 连续使用不得超过10次/天;
3. 郑重声明:
(1)禁止相同的内容多个手机号连续一条一条提交. 否则禁用帐号,由此带来损失由客户自行负责.
(2)请客户提供外网服务器IP以便于绑定IP发送,提高账号的安全性!
(3)在程序里最好有配置文件,程序自动判断当某个接口连接超时提交速度变慢时.程序可以自动切换其它的接口以下是推荐的几个服务器,仅接口地址不同而已.方法全部相同;
地址1:http://sdk3.entinfo.cn:8060/webservice.asmx
这些地址都是标准的webservice地址,C#,Java客户可以按照自己熟悉的方式去解析String
或者
地址1:http://sdk3.entinfo.cn:8060/webservice.asmx?wsdl
六、示例Demo源代码下载:
DEMO SDK彩信接口文档 所有下载