• c# 微信开发 《生成菜单》


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using TalentCloud.Base.Entities;
    using TalentCloud.Base.Utils;
    
    namespace TalentCloud.Agriculture.Weixin.Web.Weixin
    {
        public partial class CreateMenu : System.Web.UI.Page
        {
            public string output;
            protected void Page_Load(object sender, EventArgs e)
            {
    //满足JSON格式 string menu = "{

    "button": [{
    "type": "view",
    "name": "11",
    "url": "http://www.baidu.com/Weixin/wxProcess.aspx?reurl=http://www.baidu.com"
    }, {
    "type": "view",
    "name": "22",
    "url": "http://www.baidu.com/Weixin/wxProcess.aspx?reurl=http://www.baidu.com"
    }, {
    "name": "55",
    "sub_button": [{
    "type": "view",
    "name": "55-1",
    "url": "http://www.baidu.com/Weixin/wxProcess.aspx?reurl=http://www.baidu.com"
    }, {
    "type": "click",
    "name": "55-2",
    "key": "BTN_QRCODE"
    }]
    }]
    }";

                string access_token = WeiXinCommom.GetAccsss_token();
           //生成微信菜单 string i = WeiXinCommom.PostData("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + access_token, menu); output = i;//一定要返回成功,不返回就是失败 } } }

      

     /// <summary>
            /// 获取access_token
            /// </summary>
            /// <returns></returns>
            public static string GetAccsss_token()
            {
                string access_token = CheckAccsss_token();
                if (!string.IsNullOrWhiteSpace(access_token))
                {
                    return access_token;
                }
                else
                {
                    //自定义菜单token的获取 是用 下面的两个参数 获取的 不能直接用 公众平台的token
                    string url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + appsecret + "";
                    access_token = GetData(url);
                    access_token = access_token.Substring(17, access_token.Length - 37);
                    //更新access_token的值和获取时间
                    WeixinDA.UpdateCodeConfig(access_token, "Access_tokenID");
                    return access_token;
                }
            }
    

      

  • 相关阅读:
    安卓平台下ARM Mali OpenCL编程-GPU信息检测(转)
    Android 常用的性能分析工具详解:GPU呈现模式, TraceView, Systrace, HirearchyViewer(转)
    windows配置meld
    nginx的学习材料
    nginx+lua组合的web框架
    [转] Linux下防火墙iptables用法规则详及其防火墙配置
    转:关于知乎音视频学习入门的解答
    转: 在创业公司使用C++
    【转】 消息队列设计精要
    转: __asm__ __volatile__内嵌汇编用法简述
  • 原文地址:https://www.cnblogs.com/yyyuguo/p/8426745.html
Copyright © 2020-2023  润新知