微信投票验证

if (Convert.ToInt64(Session["tokentime"]) < DateTime.Now.Ticks)
                            {
                                Session["tokentime"] = DateTime.Now.AddSeconds(720).Ticks;
                                Newtonsoft.Json.Linq.JObject jobj = Newtonsoft.Json.Linq.JObject.Parse(GetData("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid_ + "&secret=" + AppSecret));
                                if (jobj["access_token"] != null)
                                {
                                    Session["access"] = jobj["access_token"];
                                }
                                else
                                {
                                    Session["access"] = "";
                                }
                            }
                            if (!string.IsNullOrEmpty(Session["access"].ToString()))
                            {
                                Newtonsoft.Json.Linq.JObject jobj2 = Newtonsoft.Json.Linq.JObject.Parse(GetData("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + Session["access"] + "&openid="+tpopenid+"&lang=zh_CN"));
                                if (jobj2["openid"] != null)
                                {
                                      //验证openid是正确的openid
                                }
                                else
                                {
                                    msg = ("投票失败,请检查格式和投票编号。投票格式为:投票XX");
                                }
                            }
                            else {
                                msg = ("投票失败,请稍后再试。");
                            }

 

posted @ 2014-12-22 11:10  c-Sharp  阅读(555)  评论(0)    收藏  举报