//创建微信企业号菜单栏
public static string CustomMenu()
{
//获取Token
string AppUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?";
string AppID = "wxc230dd116f51778d";
string AppSecret = "s3O7Hzmo70kI69S-ghQ5KbF0-A9U0YuZm7IRvBLjwx7grbUJN18XLKV01MwZ51DR";
WebClient webClient = new WebClient();
Byte[] bytes = webClient.DownloadData(string.Format("{0}corpid={1}&corpsecret={2}", AppUrl, AppID, AppSecret));
string result = Encoding.GetEncoding("utf-8").GetString(bytes);
JObject jObj = JObject.Parse(result);
string token = jObj["access_token"].ToString();
//进行创建菜单栏操作
string CustomMenuEdit = "";
CustomMenuEdit += "{\n";
CustomMenuEdit += "\"button\":[\n";
CustomMenuEdit += "{\n";
CustomMenuEdit += "\"type\":\"click\",\n";
CustomMenuEdit += "\"name\":\"专业领航\",\n";
CustomMenuEdit += "\"key\":\"V1001_TODAY_MUSIC123eee\"\n";
CustomMenuEdit += "},\n";
CustomMenuEdit += "{\n";
CustomMenuEdit += "\"type\":\"click\",\n";
CustomMenuEdit += "\"name\":\"探究中金\",\n";
CustomMenuEdit += "\"key\":\"V1001_TODAY_SINGER123eee\"\n";
CustomMenuEdit += "},\n";
CustomMenuEdit += "{\n";
CustomMenuEdit += "\"name\":\"dms数据监控\",\n";
CustomMenuEdit += "\"sub_button\":[\n";
CustomMenuEdit += "{\n";
CustomMenuEdit += "\"type\":\"view\",\n";
CustomMenuEdit += "\"name\":\"dms数据监控\",\n";
CustomMenuEdit += "\"url\":\"http://112.84.186.217:8010/MobileInfo/Index\"\n";
CustomMenuEdit += "}]\n";
CustomMenuEdit += "}]\n";
CustomMenuEdit += "}\n";
string url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?access_token=" + token + "&agentid="+2;
WebRequest req = WebRequest.Create(url);
JavaScriptSerializer aa = new JavaScriptSerializer();
byte[] requestBytes = Encoding.UTF8.GetBytes(CustomMenuEdit);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.Default);
string backstr = sr.ReadToEnd();
sr.Close();
res.Close();
WeChatReturn WCR = aa.Deserialize<WeChatReturn>(backstr);
return WCR.errmsg;
}