public static JsonData get_info(string access_token, string open_id) { string strUrl = "https://api.weibo.com/2/users/show.json?access_token=" + access_token + "&uid=" + open_id; string text = NetWorkUtils.HttpGet(strUrl); JsonData result; if (text.Contains("error")) { result = null; } else { try { JsonData jsonData = JsonMapper.ToObject(text); if (jsonData.Count > 0) { result = jsonData; return(result); } } catch { result = null; return(result); } result = null; } return(result); }
public static Dictionary <string, object> get_user_info(string access_token, string open_id) { OAuthConfig oAuthConfig = OAuthConfig.GetOAuthConfig("qq"); string strUrl = string.Concat(new string[] { "https://graph.qq.com/user/get_user_info?access_token=", access_token, "&oauth_consumer_key=", oAuthConfig.OAuthAppId, "&openid=", open_id }); string text = NetWorkUtils.HttpGet(strUrl); Dictionary <string, object> result; if (text.Contains("error")) { result = null; } else { Dictionary <string, object> dictionary = JsonMapper.ToObject <Dictionary <string, object> >(text); result = dictionary; } return(result); }
public static Dictionary <string, object> get_access_token(string code, string state) { OAuthConfig oAuthConfig = OAuthConfig.GetOAuthConfig("qq"); string strUrl = string.Concat(new string[] { "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=", oAuthConfig.OAuthAppId, "&client_secret=", oAuthConfig.OAuthAppKey, "&code=", code, "&state=", state, "&redirect_uri=", HttpContext.Current.Server.UrlEncode(oAuthConfig.ReturnUri) }); string text = NetWorkUtils.HttpGet(strUrl); Dictionary <string, object> result; if (text.Contains("error")) { result = null; } else { try { string[] array = text.Split(new char[] { '&' }); string value = array[0].Split(new char[] { '=' })[1]; string value2 = array[1].Split(new char[] { '=' })[1]; result = new Dictionary <string, object> { { "access_token", value }, { "expires_in", value2 } }; } catch { result = null; } } return(result); }
public void TestNetwork() { var getStr = NetWorkUtils.HttpGet("http://www.singoo.top"); Console.WriteLine("get返回数据:" + getStr); var postStr = NetWorkUtils.HttpPost("http://passports.singoo.top/passports/login", "_loginname=admin&_loginpwd=123"); Console.WriteLine("post返回数据:" + postStr); }
public static string Get(string strKey, string strExpressCompanyCode, string strExpressNo) { return(NetWorkUtils.HttpGet(string.Concat(new string[] { "http://www.kuaidi100.com/applyurl?key=", strKey, "&com=", strExpressCompanyCode, "&nu=", strExpressNo }))); }
public static string GetJSON() { string result; try { result = NetWorkUtils.HttpGet("http://www.ue.net.cn/api/uenews.json"); } catch { result = string.Empty; } return(result); }
public static Dictionary <string, object> get_open_id(string access_token) { string strUrl = "https://graph.qq.com/oauth2.0/me?access_token=" + access_token; string text = NetWorkUtils.HttpGet(strUrl); Dictionary <string, object> result; if (text.Contains("error")) { result = null; } else { int num = text.IndexOf('(') + 1; int num2 = text.LastIndexOf(')') - 1; text = text.Substring(num, num2 - num); Dictionary <string, object> dictionary = JsonMapper.ToObject <Dictionary <string, object> >(text); result = dictionary; } return(result); }
public static JsonData get_info(string access_token, string open_id) { OAuthConfig oAuthConfig = OAuthConfig.GetOAuthConfig("qq"); string strUrl = string.Concat(new string[] { "https://graph.qq.com/user/get_info?access_token=", access_token, "&oauth_consumer_key=", oAuthConfig.OAuthAppId, "&openid=", open_id }); string text = NetWorkUtils.HttpGet(strUrl); JsonData result; if (text.Contains("error")) { result = null; } else { try { JsonData jsonData = JsonMapper.ToObject(text); if (jsonData.Count > 0) { result = jsonData; return(result); } } catch { result = null; return(result); } result = null; } return(result); }
private void LoadFromServer() { AccessTokenResult token = CommonApi.GetToken(SinGooCMS.Weixin.Config.AppID, SinGooCMS.Weixin.Config.AppSecret, "client_credential"); string strUrl = string.Format("https://api.weixin.qq.com/cgi-bin/menu/get?access_token={0}", token.access_token); string strValue = NetWorkUtils.HttpGet(strUrl); GetMenuResultFull getMenuResultFull = JsonUtils.JsonToObject <GetMenuResultFull>(strValue); if (getMenuResultFull != null && getMenuResultFull.menu != null && getMenuResultFull.menu.button.Count > 0) { WxMenu.EmptyLocal(); int num = 1; foreach (MenuFull_RootButton current in getMenuResultFull.menu.button) { WxMenuInfo wxMenuInfo = new WxMenuInfo { RootID = 0, ParentID = 0, Type = (current.type ?? string.Empty), Name = current.name, EventKey = (current.key ?? string.Empty), Url = (current.url ?? string.Empty), ChildCount = 0, ChildIDs = string.Empty, Sort = num, AutoTimeStamp = System.DateTime.Now }; int num2 = WxMenu.Add(wxMenuInfo); if (num2 > 0) { wxMenuInfo.AutoID = num2; wxMenuInfo.RootID = num2; num++; if (current.sub_button != null && current.sub_button.Count > 0) { wxMenuInfo.ChildCount = current.sub_button.Count; int num3 = 1; foreach (MenuFull_RootButton current2 in current.sub_button) { WxMenuInfo entity = new WxMenuInfo { RootID = num2, ParentID = num2, Type = (current2.type ?? string.Empty), Name = current2.name, EventKey = (current2.key ?? string.Empty), Url = (current2.url ?? string.Empty), ChildCount = 0, ChildIDs = string.Empty, Sort = num3, AutoTimeStamp = System.DateTime.Now }; int num4 = WxMenu.Add(entity); if (num4 > 0) { WxMenuInfo expr_27E = wxMenuInfo; expr_27E.ChildIDs = expr_27E.ChildIDs + num4 + ","; num3++; } } } if (wxMenuInfo.ChildIDs.EndsWith(",")) { wxMenuInfo.ChildIDs = wxMenuInfo.ChildIDs.TrimEnd(new char[] { ',' }); } WxMenu.Update(wxMenuInfo); } } } this.BindData(); }