Exemplo n.º 1
0
        public static Dictionary <string, object> get_access_token(string code, string state)
        {
            oauth_config config = oauth_helper.get_config("qq");
            string       str    = Utils.HttpGet("https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=" + config.oauth_app_id + "&client_secret=" + config.oauth_app_key + "&code=" + code + "&state=" + state + "&redirect_uri=" + Utils.UrlEncode(config.return_uri));

            if (str.Contains("error"))
            {
                return((Dictionary <string, object>)null);
            }
            try
            {
                string[] strArray = str.Split('&');
                return(new Dictionary <string, object>()
                {
                    {
                        "access_token",
                        (object)strArray[0].Split('=')[1]
                    },
                    {
                        "expires_in",
                        (object)strArray[1].Split('=')[1]
                    }
                });
            }
            catch
            {
                return((Dictionary <string, object>)null);
            }
        }
Exemplo n.º 2
0
        public static Dictionary <string, object> get_info(string access_token, string fields)
        {
            oauth_config  config        = oauth_helper.get_config("renren");
            string        url           = "http://api.renren.com/restserver.do";
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("method=users.getInfo&");
            stringBuilder.Append("access_token=" + access_token + "&");
            stringBuilder.Append("fields=" + fields + "&");
            stringBuilder.Append("format=json&");
            stringBuilder.Append("v=1.0&");
            stringBuilder.Append("sig=" + renren_helper.MD5Encrpt("access_token=" + access_token + "fields=" + fields + "format=jsonmethod=users.getInfov=1.0" + config.oauth_app_key));
            string jsonText = Rain.Common.Utils.HttpPost(url, stringBuilder.ToString());

            if (jsonText.Contains("error"))
            {
                return((Dictionary <string, object>)null);
            }
            try
            {
                Dictionary <string, object> dictionary = JsonHelper.DataRowFromJSON(jsonText);
                if (dictionary.Count > 0)
                {
                    return(dictionary);
                }
            }
            catch
            {
                return((Dictionary <string, object>)null);
            }
            return((Dictionary <string, object>)null);
        }
Exemplo n.º 3
0
        public static Dictionary <string, object> get_user_info(
            string access_token,
            string open_id)
        {
            oauth_config config   = oauth_helper.get_config("qq");
            string       jsonText = Utils.HttpGet("https://graph.qq.com/user/get_user_info?access_token=" + access_token + "&oauth_consumer_key=" + config.oauth_app_id + "&openid=" + open_id);

            if (jsonText.Contains("error"))
            {
                return((Dictionary <string, object>)null);
            }
            return(JsonHelper.DataRowFromJSON(jsonText));
        }
Exemplo n.º 4
0
        public static Dictionary <string, object> get_access_token(string code)
        {
            oauth_config config   = oauth_helper.get_config("sina");
            string       jsonText = Utils.HttpPost("https://api.weibo.com/oauth2/access_token", "grant_type=authorization_code&code=" + code + "&client_id=" + config.oauth_app_id + "&client_secret=" + config.oauth_app_key + "&redirect_uri=" + Utils.UrlEncode(config.return_uri));

            if (jsonText.Contains("error"))
            {
                return((Dictionary <string, object>)null);
            }
            try
            {
                return(JsonHelper.DataRowFromJSON(jsonText));
            }
            catch
            {
                return((Dictionary <string, object>)null);
            }
        }
Exemplo n.º 5
0
        public static Dictionary <string, object> get_access_token(string code)
        {
            oauth_config config   = oauth_helper.get_config("renren");
            string       jsonText = Rain.Common.Utils.HttpGet("https://graph.renren.com/oauth/token?grant_type=authorization_code&client_id=" + config.oauth_app_id + "&client_secret=" + config.oauth_app_key + "&code=" + code + "&redirect_uri=" + Rain.Common.Utils.UrlEncode(config.return_uri));

            if (jsonText.Contains("error"))
            {
                return((Dictionary <string, object>)null);
            }
            try
            {
                Dictionary <string, object> dictionary = JsonHelper.DataRowFromJSON(jsonText);
                if (dictionary.Count > 0)
                {
                    return(dictionary);
                }
            }
            catch
            {
                return((Dictionary <string, object>)null);
            }
            return((Dictionary <string, object>)null);
        }