Beispiel #1
0
        /// <summary>
        /// 创建卡券
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="cardType">卡券类型</param>
        /// <param name="data">创建卡券需要的数据,格式可以看CardCreateData.cs</param>
        /// <returns></returns>
        public static CardCreateResultJson Card_Create(string accessToken, CardType cardType, object data)
        {
            var urlFormat = string.Format("https://api.weixin.qq.com/card/create?access_token={0}", accessToken);

            BaseCardCreateInfo cardData = null;

            switch (cardType)
            {
                case CardType.GENERAL_COUPON:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_GeneralCoupon()
                        {
                            card_type = cardType,
                            general_coupon = data as Card_GeneralCouponData
                        }
                    };
                    break;
                case CardType.GROUPON:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_Groupon()
                        {
                            card_type = cardType,
                            groupon = data as Card_GrouponData
                        }
                    };
                    break;
                case CardType.GIFT:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_Gift()
                        {
                            card_type = cardType,
                            gift = data as Card_GiftData
                        }
                    };
                    break;
                case CardType.CASH:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_Cash()
                        {
                            card_type = cardType,
                            cash = data as Card_CashData
                        }
                    };
                    break;
                case CardType.DISCOUNT:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_DisCount()
                        {
                            card_type = cardType,
                            discount = data as Card_DisCountData
                        }
                    };
                    break;
                case CardType.MEMBER_CARD:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_MemberCard()
                        {
                            card_type = cardType,
                            member_card = data as Card_MemberCardData
                        }
                    };
                    break;
                case CardType.SCENIC_TICKET:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_ScenicTicket()
                        {
                            card_type = cardType,
                            scenic_ticket = data as Card_ScenicTicketData
                        }
                    };
                    break;
                case CardType.MOVIE_TICKET:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_MovieTicket()
                        {
                            card_type = cardType,
                            movie_ticket = data as Card_MovieTicketData
                        }
                    };
                    break;
                case CardType.BOARDING_PASS:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_BoardingPass()
                        {
                            card_type = cardType,
                            boarding_pass = data as Card_BoardingPassData
                        }
                    };
                    break;
                case CardType.LUCKY_MONEY:
                    cardData = new BaseCardCreateInfo()
                    {
                        card = new Card_LuckyMoney()
                        {
                            card_type = cardType,
                            lucky_money = data as Card_LuckyMoneyData
                        }
                    };
                    break;
                default:
                    break;
            }

            return CommonJsonSend.Send<CardCreateResultJson>(null, urlFormat, cardData);
        }
        /// <summary>
        /// 检验授权凭证(access_token)是否有效
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="openId">用户的唯一标识</param>
        /// <returns></returns>
        public static WxJsonResult Auth(string accessToken, string openId)
        {
            var url = string.Format("https://api.weixin.qq.com/sns/auth?access_token={0}&openid={1}", accessToken, openId);

            return(CommonJsonSend.Send <WxJsonResult>(null, url, null, CommonJsonSendType.GET));
        }
Beispiel #3
0
        /// <summary>
        /// 获取颜色列表接口
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public static GetColorsResultJson Card_GetColors(string accessToken)
        {
            var urlFormat = string.Format("https://api.weixin.qq.com/card/getcolors?access_token={0}", accessToken);

            return CommonJsonSend.Send<GetColorsResultJson>(null, urlFormat, null);
        }
        /// <summary>
        /// 创建菜单
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="buttonData"></param>
        /// <returns></returns>
        public static WxJsonResult CreateMenu(string accessToken, ButtonGroup buttonData)
        {
            var urlFormat = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}";

            return(CommonJsonSend.Send(accessToken, urlFormat, buttonData));
        }