Ejemplo n.º 1
0
 /// <summary>
 /// 获取AccessToken
 /// </summary>
 private void GetAccessToken()
 {
     HttpHelper http = new HttpHelper();
     HttpItem item = new HttpItem();
     item.URL = string.Format("{0}token?grant_type=client_credential&appid={1}&secret={2}", config.APIUrl, config.AppID, config.AppSecret);
     string json = http.GetHtml(item);
     var data = new WeChatData(json);
     config.AccessToken = data["access_token"];
     config.ExpiresIn = DateTime.Now.AddSeconds(data.Get<int>("expires_in"));
 }
Ejemplo n.º 2
0
 private void GetAccessToken()
 {
     HttpLibSyncRequestItem item = new HttpLibSyncRequestItem();
     item.Url = string.Format("{0}token?grant_type=client_credential&appid={1}&secret={2}", _config.ApiUrl, _config.AppId, _config.AppSecret);
     string json = HttpLibSyncRequest.Get(item);
     var data = new WeChatData(json);
     _config.AccessToken = data["access_token"];
     _config.ExpiresIn = DateTime.Now.AddSeconds(data.Get<int>("expires_in"));
 }