成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

如何使用c#開發(fā)公眾平臺自定義菜單功能-創(chuàng)新互聯(lián)

這篇文章主要介紹如何使用c#開發(fā)公眾平臺自定義菜單功能,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

網(wǎng)站設(shè)計制作過程拒絕使用模板建站;使用PHP+MYSQL原生開發(fā)可交付網(wǎng)站源代碼;符合網(wǎng)站優(yōu)化排名的后臺管理系統(tǒng);成都做網(wǎng)站、網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè)收費(fèi)合理;免費(fèi)進(jìn)行網(wǎng)站備案等企業(yè)網(wǎng)站建設(shè)一條龍服務(wù).我們是一家持續(xù)穩(wěn)定運(yùn)營了10年的成都創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司。

代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cm.aspx.cs" Inherits="guotaotao_weixin.cm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/tupian/20230522/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>

復(fù)制代碼 代碼如下:

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();
            }
        }
    }
}

復(fù)制代碼 代碼如下:

namespace guotaotao_weixin {
    
    public partial class cm {
        /// <summary>
        /// form1 控件。
        /// </summary>
        /// <remarks>
        /// 自動生成的字段。
        /// 若要進(jìn)行修改,請將字段聲明從設(shè)計器文件移到代碼隱藏文件。
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        /// <summary>
        /// lt_msg 控件。
        /// </summary>
        /// <remarks>
        /// 自動生成的字段。
        /// 若要進(jìn)行修改,請將字段聲明從設(shè)計器文件移到代碼隱藏文件。
        /// </remarks>
        protected global::System.Web.UI.WebControls.Literal lt_msg;
    }
}

復(fù)制代碼 代碼如下:

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 "構(gòu)造函數(shù)"
            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\":\"產(chǎn)品\"," + "\r\n";
            postData += "\"sub_button\":[" + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"click\"," + "\r\n";
            postData += "   \"name\":\"無糖系列\(zhòng)", " + "\r\n";
            postData += "   \"key\":\"gtt_menu_001001\"" + "\r\n";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"click\"," + "\r\n";
            postData += "   \"name\":\"干果系列\(zhòng)", " + "\r\n";
            postData += "   \"key\":\"gtt_menu_001002\"" + "\r\n";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"click\"," + "\r\n";
            postData += "   \"name\":\"休閑系列\(zhòng)", " + "\r\n";
            postData += "   \"key\":\"gtt_menu_001003\"" + "\r\n";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"click\"," + "\r\n";
            postData += "   \"name\":\"兒童系列\(zhòng)", " + "\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\":\"/tupian/20230522/honor_list.aspx%5C"" + "%5Cr%5Cn";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"click\"," + "\r\n";
            postData += "   \"name\":\"優(yōu)惠券\", " + "\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 += "{ " + "\r\n";
            postData += "   \"type\":\"view\"," + "\r\n";
            postData += "   \"name\":\"關(guān)于我們\", " + "\r\n";
            postData += "   \"url\":\"/tupian/20230522/aboutus.aspx%5C"" + "%5Cr%5Cn";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"view\"," + "\r\n";
            postData += "   \"name\":\"聯(lián)系我們\", " + "\r\n";
            postData += "   \"url\":\"/tupian/20230522/contactus.aspx%5C"" + "%5Cr%5Cn";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"view\"," + "\r\n";
            postData += "   \"name\":\"查詢訂單\", " + "\r\n";
            postData += "   \"url\":\"/tupian/20230522/orders_chaxun.aspx%5C"" + "%5Cr%5Cn";
            postData += "}," + "\r\n";
            postData += "{ " + "\r\n";
            postData += "   \"type\":\"view\"," + "\r\n";
            postData += "   \"name\":\"留言反饋\", " + "\r\n";
            postData += "   \"url\":\"/tupian/20230522/feedback.aspx%5C"" + "%5Cr%5Cn";
            postData += " }]" + "\r\n";
            postData += "}]" + "\r\n";
            postData += "}" + "\r\n";
            return postData;
        }
    }
}


菜單中的URL地址換成自己的

復(fù)制代碼 代碼如下:

using System;
using System.Web.Security;
using System.Xml;
using aaa_weixin.database;
using Newtonsoft.Json;
namespace aaa_weixin
{
    public class weixin
    {
        private string Token = ""; //微信里面開發(fā)者模式Token
        private string devlopID = "";//微信里面開發(fā)者模式:開發(fā)者ID
        private string devlogPsw = "";//微信里面開發(fā)者模式: 開發(fā)者密碼
        public string AccessToken = ""; //獲取的通行證
        public void Auth()
        {
            string echoStr = System.Web.HttpContext.Current.Request.QueryString["echoStr"];
            if (CheckSignature())
            {
                if (!string.IsNullOrEmpty(echoStr))
                {
                    System.Web.HttpContext.Current.Response.Write(echoStr);
                    System.Web.HttpContext.Current.Response.End();
                }
            }
        }
        public string GetAccessToken() //獲取通行證
        {            
            string url_token = "/tupian/20230522/token
            string result = func.webRequestGet(url_token);
            accessToken deserializedProduct = (accessToken)JsonConvert.DeserializeObject(result, typeof(accessToken));
            this.AccessToken  = deserializedProduct.access_Token;
            return this.AccessToken;
        }
        public string GetMenu() //獲取當(dāng)前菜單情況
        {
            string url_Menu_Get = "/tupian/20230522/get
            string output = func.webRequestGet(url_Menu_Get);
            //wxErr deserializedProduct = (wxErr)JsonConvert.DeserializeObject(output, typeof(wxErr));
            //return deserializedProduct.errmsg;
            return output;
        }
        public string SetMenu() //設(shè)置新菜單
        {
            string url_Menu_Create = "/tupian/20230522/create
            aaa gtt = new aaa();
            string postData = gtt.createMenuDate();
            string result = func.webRequestPost(url_Menu_Create,postData);
            return result;
        }
        public string DelMenu() //刪除菜單
        {
            string url_Menu_Delete = "/tupian/20230522/delete
            string result = func.webRequestGet(url_Menu_Delete);
            return result;
        }
        /// <summary>
        /// 驗證微信簽名
        /// </summary>
        /// * 將token、timestamp、nonce三個參數(shù)進(jìn)行字典序排序
        /// * 將三個參數(shù)字符串拼接成一個字符串進(jìn)行sha1加密
        /// * 開發(fā)者獲得加密后的字符串可與signature對比,標(biāo)識該請求來源于微信。
        /// <returns></returns>
        private bool CheckSignature()
        {
            string signature = System.Web.HttpContext.Current.Request.QueryString["signature"];
            string timestamp = System.Web.HttpContext.Current.Request.QueryString["timestamp"];
            string nonce = System.Web.HttpContext.Current.Request.QueryString["nonce"];
            string[] ArrTmp = { Token, timestamp, nonce };
            Array.Sort(ArrTmp);     //字典排序
            string tmpStr = string.Join("", ArrTmp);
            tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
            tmpStr = tmpStr.ToLower();
            if (tmpStr == signature)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
    public class wxErr
    {
        private int Errcode;
        public int errcode
        {
            get { return Errcode; }
            set { Errcode = value; }
        }
        private string Errmsg;
        public string errmsg
        {
            get { return Errmsg; }
            set { Errmsg = value; }
        }
    }
    public class accessToken
    {
        private string access_token;
        public string access_Token
        {
            get { return access_token; }
            set { access_token = value; }
        }
        private int expires_in;
        public int expires_In
        {
            get { return expires_in; }
            set { expires_in = value; }
        } 
    }
 }

以上是“如何使用c#開發(fā)公眾平臺自定義菜單功能”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

本文標(biāo)題:如何使用c#開發(fā)公眾平臺自定義菜單功能-創(chuàng)新互聯(lián)
鏈接URL:http://jinyejixie.com/article38/djsipp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作網(wǎng)站收錄、軟件開發(fā)、做網(wǎng)站、定制網(wǎng)站網(wǎng)站排名

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)
利津县| 朝阳区| 曲周县| 开原市| 环江| 西充县| 珲春市| 绥中县| 乡宁县| 方正县| 紫云| 苗栗县| 新平| 麻江县| 威海市| 乌恰县| 黔东| 西华县| 绥化市| 马边| 乐业县| 武义县| 英超| 双流县| 弋阳县| 宣化县| 莱阳市| 屏东市| 佳木斯市| 桂林市| 大港区| 荔浦县| 合水县| 嘉善县| 连城县| 南澳县| 澳门| 长宁县| 贡觉县| 额敏县| 共和县|