匿名通过本文主要向大家介绍了c# 公众平台自定义菜单等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
微信公众平台服务号开放了自定义菜单API,本案例介绍C#开发微信公众号自定义菜单功能。在此基础上可以开发更完善的自定义菜单管理功能
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cm.aspx.cs" Inherits="guotaotao_weixin.cm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>test</title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:Literal ID="lt_msg" runat="server" ></asp:Literal>
</p>
</form>
</body>
</html>复制代码 代码如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace guotaotao_weixin
{
public partial class cm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
weixin wx = new weixin();
//lt_msg.Text = wx.GetAccessToken();
lt_msg.Text = wx.DelMenu();
lt_msg.Text += wx.SetMenu();
}
}
}
}复制代码 代码如下:
namespace guotaotao_weixin {
public partial class cm {
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// lt_msg 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Literal lt_msg;
}
}复制代码 代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using guotaotao_weixin.database;
using guotaotao.database;
namespace guotaotao_weixin
{
public class guotaotao
{
private string _content = "";
private string _FromUserName = "";
public int msgType = 0;
public int isFirst = 0;
public int pid = 0;
#region "构造函数"
public guotaotao()
{
}
public guotaotao(string content)
{
this._content = content;
}
public guotaotao(string content,string FromUserName)
{
this._content = content;
this._FromUserName = FromUserName;
}
#endregion
public string createMenuDate()
{
string postData = "{" + "\r\n";
postData += "\"button\":[ " + "\r\n";
postData += "{ " + "\r\n";
postData += "\"name\":\"产品\"," + "\r\n";
postData += "\"sub_button\":[" + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"click\"," + "\r\n";
postData += " \"name\":\"无糖系列\", " + "\r\n";
postData += " \"key\":\"gtt_menu_001001\"" + "\r\n";
postData += "}," + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"click\"," + "\r\n";
postData += " \"name\":\"干果系列\", " + "\r\n";
postData += " \"key\":\"gtt_menu_001002\"" + "\r\n";
postData += "}," + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"click\"," + "\r\n";
postData += " \"name\":\"休闲系列\", " + "\r\n";
postData += " \"key\":\"gtt_menu_001003\"" + "\r\n";
postData += "}," + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"click\"," + "\r\n";
postData += " \"name\":\"儿童系列\", " + "\r\n";
postData += " \"key\":\"gtt_menu_001004\"" + "\r\n";
postData += " }]" + "\r\n";
postData += "}," + "\r\n";
postData += "{" + "\r\n";
postData += "\"name\":\"活动\", " + "\r\n";
postData += "\"sub_button\":[" + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"click\"," + "\r\n";
postData += " \"name\":\"抽奖\", " + "\r\n";
postData += " \"key\":\"gtt_menu_002001\"" + "\r\n";
postData += "}," + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"view\"," + "\r\n";
postData += " \"name\":\"获奖名单\", " + "\r\n";
postData += " \"url\":\"http://www.aaa.com/apps/honor_list.aspx\"" + "\r\n";
postData += "}," + "\r\n";
postData += "{ " + "\r\n";
postData += " \"type\":\"click\"," + "\r\n";
postData += " \"name\":\"优惠券\", " + "\r\n";
postData += " \"key\":\"gtt_menu_002003\"" + "\r\n";
postData += " }]" + "\r\n";
postData += "}," + "\r\n";
postData += "{" + "\r\n";
postData += "\"name\":\"帮助\"," + "\r\n";
postData += "\"sub_button\":[" + "\r\n";
postData

