版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
【移動應(yīng)用開發(fā)技術(shù)】微信開發(fā)中有關(guān)高級群發(fā)文本的示例分析
/upload/information/20201208/260/14027.jpg/upload/information/20201208/260/14028.jpg綁定本月剩余群發(fā)條數(shù)
///
<summary>
///
綁定本月剩余群發(fā)條數(shù)
///
</summary>
private
void
BindMassCount()
{
WxMassService
wms
=
new
WxMassService();
List<WxMassInfo>
wxmaslist
=
wms.GetMonthMassCount();
//官方微信服務(wù)號每月只能群發(fā)4條信息,(訂閱號每天1條)多余信息,將不會成功推送,這里已經(jīng)設(shè)定為4
this.lbMassCounts.Text
=
(4
-
int.Parse(wxmaslist.Count.ToString())).ToString();
if
(wxmaslist.Count
>=
4)
{
this.LinkBtnSubSend.Enabled
=
false;
this.LinkBtnSubSend.Attributes.Add("Onclick",
"return
confirm('群發(fā)信息已達上限!請下月初再試!')");
}
else
{
this.LinkBtnSubSend.Enabled
=
true;
this.LinkBtnSubSend.Attributes.Add("Onclick",
"return
confirm('您確定要群發(fā)此條信息??')");
}
}綁定分組列表
///
<summary>
///
綁定分組列表
///
</summary>
private
void
BindGroupList()
{
WeiXinServer
wxs
=
new
WeiXinServer();
///從緩存讀取accesstoken
string
Access_token
=
Cache["Access_token"]
as
string;
if
(Access_token
==
null)
{
//如果為空,重新獲取
Access_token
=
wxs.GetAccessToken();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("Access_token",
Access_token,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
string
Access_tokento
=
Access_token.Substring(17,
Access_token.Length
-
37);
string
jsonres
=
"";
string
content
=
Cache["AllGroups_content"]
as
string;
if
(content
==
null)
{
jsonres
=
"/cgi-bin/groups/get?access_token="
+
Access_tokento;
HttpWebRequest
myRequest
=
(HttpWebRequest)WebRequest.Create(jsonres);
myRequest.Method
=
"GET";
HttpWebResponse
myResponse
=
(HttpWebResponse)myRequest.GetResponse();
StreamReader
reader
=
new
StreamReader(myResponse.GetResponseStream(),
Encoding.UTF8);
content
=
reader.ReadToEnd();
reader.Close();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("AllGroups_content",
content,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
//使用前需要引用Newtonsoft.json.dll文件
JObject
jsonObj
=
JObject.Parse(content);
int
groupsnum
=
jsonObj["groups"].Count();
this.DDLGroupList.Items.Clear();//清除
for
(int
i
=
0;
i
<
groupsnum;
i++)
{
this.DDLGroupList.Items.Add(new
ListItem(jsonObj["groups"][i]["name"].ToString()
+
"("
+
jsonObj["groups"][i]["count"].ToString()
+
")",
jsonObj["groups"][i]["id"].ToString()));
}
}
///
<summary>
///
選擇群發(fā)對象類型,顯示隱藏分組列表項
///
</summary>
///
<param
name="sender"></param>
///
<param
name="e"></param>
protected
void
DDLMassType_SelectedIndexChanged(object
sender,
EventArgs
e)
{
if
(int.Parse(this.DDLMassType.SelectedValue.ToString())
>
0)
{
this.DDLGroupList.Visible
=
true;
}
else
{
this.DDLGroupList.Visible
=
false;
}
}群發(fā)
///
<summary>
///
群發(fā)
///
</summary>
///
<param
name="sender"></param>
///
<param
name="e"></param>
protected
void
LinkBtnSubSend_Click(object
sender,
EventArgs
e)
{
//根據(jù)單選按鈕判斷類型,發(fā)送
///如果選擇的是文本消息
if
(this.RadioBtnList.SelectedValue.ToString().Equals("0"))
{
if
(String.IsNullOrWhiteSpace(this.txtwenben.InnerText.ToString().Trim()))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('請輸入您要群發(fā)文本內(nèi)容!');",
true);
return;
}
if
(this.txtwenben.InnerText.ToString().Trim().Length<10)
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('文本內(nèi)容至少需要10個字符以上!');",
true);
return;
}
WxMassService
wms
=
new
WxMassService();
List<WxMassInfo>
wxmaslist
=
wms.GetMonthMassCount();
if
(wxmaslist.Count
>=
4)
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('本月可群發(fā)消息數(shù)量已達上限!');",
true);
return;
}
else
{
//如何群發(fā)類型為全部用戶,根據(jù)openID列表群發(fā)給全部用戶,訂閱號不可用,服務(wù)號認(rèn)證后可用
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
StringBuilder
sbs
=
new
StringBuilder();
sbs.Append(GetAllUserOpenIDList());
WeiXinServer
wxs
=
new
WeiXinServer();
///從緩存讀取accesstoken
string
Access_token
=
Cache["Access_token"]
as
string;
if
(Access_token
==
null)
{
//如果為空,重新獲取
Access_token
=
wxs.GetAccessToken();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("Access_token",
Access_token,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
string
Access_tokento
=
Access_token.Substring(17,
Access_token.Length
-
37);
string
posturl
=
"/cgi-bin/message/mass/send?access_token="
+
Access_tokento;
///群發(fā)POST數(shù)據(jù)示例如下:
//
{
//
"touser":[
//
"OPENID1",
//
"OPENID2"
//
],
//
"msgtype":
"text",
//
"text":
{
"content":
"hello
from
boxer."}
//}
string
postData
=
"{\"touser\":["
+
sbs.ToString()
+
"],\"msgtype\":\"text\",\"text\":{\"content\":\""
+
this.txtwenben.InnerText.ToString()
+
"\"}";
string
tuwenres
=
wxs.GetPage(posturl,
postData);
//使用前需藥引用Newtonsoft.json.dll文件
JObject
jsonObj
=
JObject.Parse(tuwenres);
if
(jsonObj["errcode"].ToString().Equals("0"))
{
//群發(fā)成功后,保存記錄
WxMassInfo
wmi
=
new
WxMassInfo();
wmi.ImageUrl
=
"";
wmi.type
=
"文本";
wmi.contents
=
this.txtwenben.InnerText.ToString().Trim();
wmi.title
=
this.txtwenben.InnerText.ToString().Substring(0,
10)
+
"...";
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
wmi.massObject
=
this.DDLMassType.SelectedItem.Text.ToString();
}
else
{
wmi.massObject
=
this.DDLGroupList.SelectedItem.Text.ToString();
}
wmi.massStatus
=
"成功";//群發(fā)成功之后返回的狀態(tài)碼
wmi.massMessageID
=
jsonObj["msg_id"].ToString();//群發(fā)成功之后返回的消息ID
wmi.massDate
=
System.DateTime.Now.ToString();
int
num
=
wms.AddWxMassInfo(wmi);
if
(num
>
0)
{
Session["wmninfo"]
=
null;
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功!??!數(shù)據(jù)已保存!');location='WxMassManage.aspx';",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)保存失?。?);",
true);
return;
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)提交失敗??!');",
true);
return;
}
}
else
{
string
group_id
=
this.DDLGroupList.SelectedValue.ToString();
WeiXinServer
wxs
=
new
WeiXinServer();
///從緩存讀取accesstoken
string
Access_token
=
Cache["Access_token"]
as
string;
if
(Access_token
==
null)
{
//如果為空,重新獲取
Access_token
=
wxs.GetAccessToken();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("Access_token",
Access_token,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
string
Access_tokento
=
Access_token.Substring(17,
Access_token.Length
-
37);
string
posturl
=
"/cgi-bin/message/mass/send?access_token="
+
Access_tokento;
///群發(fā)POST數(shù)據(jù)示例如下:
//
{
//
"filter":{
//
"is_to_all":false
//
"group_id":"2"
//
},
//
"text":{
//
"content":"CONTENT"
//
},
//
"msgtype":"text"
//}
//}
string
postData
=
"{\"filter\":{\"is_to_all\":\"false\"\"group_id\":\""
+
group_id
+
"\"},\"text\":{\"content\":\""
+
this.txtwenben.InnerText.ToString()
+
"\"},\"msgtype\":\"text\"}";
string
tuwenres
=
wxs.GetPage(posturl,
postData);
//使用前需藥引用Newtonsoft.json.dll文件
JObject
jsonObj
=
JObject.Parse(tuwenres);
if
(jsonObj["errcode"].ToString().Equals("0"))
{
//群發(fā)成功后,保存記錄
WxMassInfo
wmi
=
new
WxMassInfo();
wmi.ImageUrl
=
"";
wmi.type
=
"文本";
wmi.contents
=
this.txtwenben.InnerText.ToString().Trim();
wmi.title
=
this.txtwenben.InnerText.ToString().Substring(0,
10)
+
"...";
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
wmi.massObject
=
this.DDLMassType.SelectedItem.Text.ToString();
}
else
{
wmi.massObject
=
this.DDLGroupList.SelectedItem.Text.ToString();
}
wmi.massStatus
=
"成功";//群發(fā)成功之后返回的狀態(tài)碼
wmi.massMessageID
=
jsonObj["msg_id"].ToString();//群發(fā)成功之后返回的消息ID
wmi.massDate
=
System.DateTime.Now.ToString();
int
num
=
wms.AddWxMassInfo(wmi);
if
(num
>
0)
{
Session["wmninfo"]
=
null;
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)已保存!');location='WxMassManage.aspx';",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)保存失敗!');",
true);
return;
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)提交失?。?!');",
true);
return;
}
}
}
}
//如果選擇的是圖文消息
if
(this.RadioBtnList.SelectedValue.ToString().Equals("1"))
{
if
(String.IsNullOrWhiteSpace(this.lbtuwenmedai_id.Text.ToString().Trim()))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('請選擇或新建圖文素材再進行群發(fā)!');",
true);
return;
}
WxMassService
wms
=
new
WxMassService();
List<WxMassInfo>
wxmaslist
=
wms.GetMonthMassCount();
if
(wxmaslist.Count
>=
4)
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('本月可群發(fā)消息數(shù)量已達上限!');",
true);
return;
}
else
{
//如何群發(fā)類型為全部用戶,根據(jù)openID列表群發(fā)給全部用戶,訂閱號不可用,服務(wù)號認(rèn)證后可用
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
StringBuilder
sbs
=
new
StringBuilder();
sbs.Append(GetAllUserOpenIDList());
WeiXinServer
wxs
=
new
WeiXinServer();
///從緩存讀取accesstoken
string
Access_token
=
Cache["Access_token"]
as
string;
if
(Access_token
==
null)
{
//如果為空,重新獲取
Access_token
=
wxs.GetAccessToken();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("Access_token",
Access_token,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
string
Access_tokento
=
Access_token.Substring(17,
Access_token.Length
-
37);
string
posturl
=
"/cgi-bin/message/mass/send?access_token="
+
Access_tokento;
///群發(fā)POST數(shù)據(jù)示例如下:
//
{
//
"touser":[
//
"OPENID1",
//
"OPENID2"
//
],
//
"mpnews":{
//
"media_id":"123dsdajkasd231jhksad"
//
},
//
"msgtype":"mpnews"
//}
string
postData
=
"{\"touser\":["
+
sbs.ToString()
+
"],\"mpnews\":{\"media_id\":\""
+
this.lbtuwenmedai_id.Text.ToString()
+
"\"},\"msgtype\":\"mpnews\"}";
string
tuwenres
=
wxs.GetPage(posturl,
postData);
//使用前需藥引用Newtonsoft.json.dll文件
JObject
jsonObj
=
JObject.Parse(tuwenres);
if
(jsonObj["errcode"].ToString().Equals("0"))
{
Session["media_id"]
=
null;
WxMassInfo
wmi
=
new
WxMassInfo();
if
(Session["wmninfo"]
!=
null)
{
WxMpNewsInfo
wmninfo
=
Session["wmninfo"]
as
WxMpNewsInfo;
wmi.title
=
wmninfo.title.ToString();
wmi.contents
=
wmninfo.contents.ToString();
wmi.ImageUrl
=
wmninfo.ImageUrl.ToString();
wmi.type
=
"圖文";
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
wmi.massObject
=
this.DDLMassType.SelectedItem.Text.ToString();
}
else
{
wmi.massObject
=
this.DDLGroupList.SelectedItem.Text.ToString();
}
wmi.massStatus
=
"成功";//群發(fā)成功之后返回的狀態(tài)碼
wmi.massMessageID
=
jsonObj["msg_id"].ToString();//群發(fā)成功之后返回的消息ID
wmi.massDate
=
System.DateTime.Now.ToString();
int
num
=
wms.AddWxMassInfo(wmi);
if
(num
>
0)
{
Session["wmninfo"]
=
null;
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)已保存!');location='WxMassManage.aspx';",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功!??!數(shù)據(jù)保存失??!');",
true);
return;
}
}
else
{
wmi.title
=
"";
wmi.contents
=
"";
wmi.ImageUrl
=
"";
wmi.type
=
"圖文";
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
wmi.massObject
=
this.DDLMassType.SelectedItem.Text.ToString();
}
else
{
wmi.massObject
=
this.DDLGroupList.SelectedItem.Text.ToString();
}
wmi.massStatus
=
"成功";//群發(fā)成功之后返回的狀態(tài)碼
wmi.massMessageID
=
jsonObj["msg_id"].ToString();//群發(fā)成功之后返回的消息ID
wmi.massDate
=
System.DateTime.Now.ToString();
int
num
=
wms.AddWxMassInfo(wmi);
if
(num
>
0)
{
Session["wmninfo"]
=
null;
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功!??!圖文部分?jǐn)?shù)據(jù)已保存!');location='WxMassManage.aspx';",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)保存失??!');",
true);
return;
}
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)提交失敗??!');",
true);
return;
}
}
else
{
//根據(jù)分組進行群發(fā),訂閱號和服務(wù)號認(rèn)證后均可用
string
group_id
=
this.DDLGroupList.SelectedValue.ToString();
WeiXinServer
wxs
=
new
WeiXinServer();
///從緩存讀取accesstoken
string
Access_token
=
Cache["Access_token"]
as
string;
if
(Access_token
==
null)
{
//如果為空,重新獲取
Access_token
=
wxs.GetAccessToken();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("Access_token",
Access_token,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
string
Access_tokento
=
Access_token.Substring(17,
Access_token.Length
-
37);
string
posturl
=
"/cgi-bin/message/mass/send?access_token="
+
Access_tokento;
///群發(fā)POST數(shù)據(jù)示例如下:
//
{
//
"filter":{
//
"is_to_all":false
//
"group_id":"2"
//
},
//
"mpnews":{
//
"media_id":"123dsdajkasd231jhksad"
//
},
//
"msgtype":"mpnews"
//}
string
postData
=
"{\"filter\":{\"is_to_all\":\"false\"\"group_id\":\""+group_id+
"\"},\"mpnews\":{\"media_id\":\""
+
this.lbtuwenmedai_id.Text.ToString()
+
"\"},\"msgtype\":\"mpnews\"}";
string
tuwenres
=
wxs.GetPage(posturl,
postData);
//使用前需藥引用Newtonsoft.json.dll文件
JObject
jsonObj
=
JObject.Parse(tuwenres);
if
(jsonObj["errcode"].ToString().Equals("0"))
{
Session["media_id"]
=
null;
WxMassInfo
wmi
=
new
WxMassInfo();
if
(Session["wmninfo"]
!=
null)
{
WxMpNewsInfo
wmninfo
=
Session["wmninfo"]
as
WxMpNewsInfo;
wmi.title
=
wmninfo.title.ToString();
wmi.contents
=
wmninfo.contents.ToString();
wmi.ImageUrl
=
wmninfo.ImageUrl.ToString();
wmi.type
=
"圖文";
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
wmi.massObject
=
this.DDLMassType.SelectedItem.Text.ToString();
}
else
{
wmi.massObject
=
this.DDLGroupList.SelectedItem.Text.ToString();
}
wmi.massStatus
=
"成功";//群發(fā)成功之后返回的狀態(tài)碼
wmi.massMessageID
=
jsonObj["msg_id"].ToString();//群發(fā)成功之后返回的消息ID
wmi.massDate
=
System.DateTime.Now.ToString();
int
num
=
wms.AddWxMassInfo(wmi);
if
(num
>
0)
{
Session["wmninfo"]
=
null;
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。。?shù)據(jù)已保存!');location='WxMassManage.aspx';",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)保存失?。?);",
true);
return;
}
}
else
{
wmi.title
=
"";
wmi.contents
=
"";
wmi.ImageUrl
=
"";
wmi.type
=
"圖文";
if
(this.DDLMassType.SelectedValue.ToString().Equals("0"))
{
wmi.massObject
=
this.DDLMassType.SelectedItem.Text.ToString();
}
else
{
wmi.massObject
=
this.DDLGroupList.SelectedItem.Text.ToString();
}
wmi.massStatus
=
"成功";//群發(fā)成功之后返回的狀態(tài)碼
wmi.massMessageID
=
jsonObj["msg_id"].ToString();//群發(fā)成功之后返回的消息ID
wmi.massDate
=
System.DateTime.Now.ToString();
int
num
=
wms.AddWxMassInfo(wmi);
if
(num
>
0)
{
Session["wmninfo"]
=
null;
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功!??!圖文部分?jǐn)?shù)據(jù)已保存!');location='WxMassManage.aspx';",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)已提交成功?。?!數(shù)據(jù)保存失?。?);",
true);
return;
}
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('群發(fā)任務(wù)提交失?。?!');",
true);
return;
}
}
}
}
}發(fā)送前預(yù)覽///
<summary>
///
發(fā)送前預(yù)覽
///
</summary>
///
<param
name="sender"></param>
///
<param
name="e"></param>
protected
void
LinkBtnSendPreview_Click(object
sender,
EventArgs
e)
{
WeiXinServer
wxs
=
new
WeiXinServer();
///從緩存讀取accesstoken
string
Access_token
=
Cache["Access_token"]
as
string;
if
(Access_token
==
null)
{
//如果為空,重新獲取
Access_token
=
wxs.GetAccessToken();
//設(shè)置緩存的數(shù)據(jù)7000秒后過期
Cache.Insert("Access_token",
Access_token,
null,
DateTime.Now.AddSeconds(7000),
System.Web.Caching.Cache.NoSlidingExpiration);
}
string
Access_tokento
=
Access_token.Substring(17,
Access_token.Length
-
37);
string
posturl
=
"/cgi-bin/message/mass/preview?access_token="
+
Access_tokento;
///如果選擇的是文本消息
if
(this.RadioBtnList.SelectedValue.ToString().Equals("0"))
{
if
(String.IsNullOrWhiteSpace(this.txtwenben.InnerText.ToString().Trim()))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('請輸入您要發(fā)送預(yù)覽的文本內(nèi)容!');",
true);
return;
}
if
(this.txttoUserName.Value.ToString().Trim().Equals("請輸入用戶微信號"))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('請輸入接收消息的用戶微信號!');",
true);
return;
}
//文本消息的json數(shù)據(jù){
//
"touser":"OPENID",
可改為對微信號預(yù)覽,例如towxname:zhangsan
//
"text":{
//
"content":"CONTENT"
//
},
//
"msgtype":"text"
//}
string
postData
=
"{\"towxname\":\""
+
this.txttoUserName.Value.ToString()
+
"\",\"text\":{\"content\":\""
+
this.txtwenben.InnerText.ToString()
+
"\"},\"msgtype\":\"text\"}";
string
tuwenres
=
wxs.GetPage(posturl,
postData);
//使用前需藥引用Newtonsoft.json.dll文件
JObject
jsonObj
=
JObject.Parse(tuwenres);
if
(jsonObj["errcode"].ToString().Equals("0"))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('發(fā)送預(yù)覽成功!!');",
true);
return;
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('發(fā)送預(yù)覽失?。?!');",
true);
return;
}
}
//如果選擇的是圖文消息
if
(this.RadioBtnList.SelectedValue.ToString().Equals("1"))
{
if(String.IsNullOrWhiteSpace(this.lbtuwenmedai_id.Text.ToString().Trim()))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('請選擇要預(yù)覽的圖文素材!');",
true);
return;
}
if
(this.txttoUserName.Value.ToString().Trim().Equals("請輸入用戶微信號"))
{
ScriptManager.RegisterClientScriptBlock(this.Page,
this.GetType(),
"",
"alert('請輸入接收消息的用戶微信號!');",
true);
return;
}
//圖文消息的json數(shù)據(jù){
//
"touser":"OPENID",
可改為對微信號預(yù)覽,例如towxname:zhangsan
//
"mpnews":{
//
"media_id":"123dsdajkasd231jhksad"
//
},
//
"msgtype":"mpnews"
//}
string
postData
=
"{\"towxname\":\""
+
this.txttoUserName.Value.ToString()
+
"\",\"mpnews\":{\"media_id\":\""
+
this.lbtuwenmedai_id.Text.ToString()
+
"\"},\"msgtype\":\"mpnews\"}";
string
tuwenres
=
wxs.GetPage(posturl,
postData);
//使用前需藥引用Newtonsoft.json.d
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《電源轉(zhuǎn)移》課件
- 《實木家具調(diào)研報告》課件
- 《香港言語治療服務(wù)》課件
- 課件人力資源開發(fā)與
- 2024年醫(yī)療設(shè)備采購與供應(yīng)合同3篇
- 2024年生產(chǎn)車間承包與人力資源整合合同范本3篇
- 改裝環(huán)衛(wèi)三輪車協(xié)議書(2篇)
- 2024年物聯(lián)網(wǎng)技術(shù)在農(nóng)業(yè)中的應(yīng)用合同
- 2025年梧州貨運從業(yè)資格證模擬考試
- 2025年珠海道路運輸從業(yè)資格證考試內(nèi)容是什么
- 壓力性損傷預(yù)防與處理流程
- DL/T 5225-2016 220kV~1000kV變電站通信設(shè)計規(guī)程
- 化工生產(chǎn)設(shè)備管理知識培訓(xùn)講義
- JSITS-0006-2022-T 江蘇省智慧航道建設(shè)技術(shù)指南
- 工時自動計算統(tǒng)計表
- 心電圖報告模板
- 學(xué)習(xí)2023年《網(wǎng)絡(luò)強國的重要思想》專題PPT
- 行駛證補辦委托書
- 汽車租賃公司安全規(guī)章制度
- 產(chǎn)前超聲檢查技術(shù)診斷規(guī)范
- 合金車間現(xiàn)場管理制度
評論
0/150
提交評論