Exemplo n.º 1
0
        public static string GetToken_Message(string appid, string secret)
        {
            string text = TokenApi.GetToken(appid, secret);

            if (text.Contains("access_token"))
            {
                text = new JavaScriptSerializer().Deserialize <Token>(text).access_token;
            }
            return(text);
        }
Exemplo n.º 2
0
        private const string FIXED_JSON_DATA2 = @"{""action_name"": ""QR_LIMIT_STR_SCENE"", ""action_info"": {""scene"": {""scene_str"":""{0}""}}}";               //接受字符串

        /// <summary>
        /// 创建二维码ticket
        /// </summary>
        public static string CreateTicket(string WeixinAppId, string WeixinAppSecret, string ticketID, bool isTemp = true)
        {
            string  token = TokenApi.GetToken(WeixinAppId, WeixinAppSecret);
            JObject obj2  = JsonConvert.DeserializeObject(token) as JObject;

            if (obj2 != null && obj2.ToString().Contains("access_token"))
            {
                token = obj2["access_token"].ToString();
            }
            string url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + token;
            //WxLogger(ticketID);
            string json = (isTemp) ? TEMP_JSON_DATA : FIXED_JSON_DATA2;

            json = json.Replace("{0}", ticketID);
            //WxLogger(json);
            string  strTICKET = new Hishop.Weixin.MP.Util.WebUtils().DoPost(url, json);
            JObject obj3      = JsonConvert.DeserializeObject(strTICKET) as JObject;

            return(obj3["ticket"].ToString());
        }