Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 private static void RemoveKey()
 {
     if (tokenItem != null)
     {
         try
         {
             string url = string.Format("http://{0}/accesstoken/removeweixinaccesstoken?format=json", host);
             string result = DoPost(url, string.Format("app_id=1&app_version=1.0&os_type=1&device_id=&version={0}", tokenItem.version));
             tokenItem = null;
         }
         catch (Exception ex)
         {
             LogUtil.Error(string.Format("清除Token信息出错:ex={0}", ex.ToString()));
         }
     }
 }
Example #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 private static void GetNewToken()
 {
     try
     {
         string url = string.Format("http://{0}/accesstoken/getweixinaccesstoken?format=json", host);
         string result = DoPost(url, "app_id=1&app_version=1.0&os_type=1&device_id=");
         if (!string.IsNullOrEmpty(result))
         {
             TokenItem item = JsonUtil<TokenItem>.FromJosn(result);
             if (item != null && item.ret == 200)
             {
                 LogUtil.Info(string.Format("正常获得Token{0}", result));
                 tokenItem = item;
             }
             else
             {
                 LogUtil.Error(string.Format("获取access_token出错{0}", result));
                 tokenItem = null;
             }
         }
         else
         {
             LogUtil.Error(string.Format("获取access_token出错{0}", result));
             tokenItem = null;
         }
     }
     catch (Exception ex)
     {
         LogUtil.Error(string.Format("获取access_token出错:ex={0}", ex.ToString()));
     }
 }