Пример #1
0
        public string Users_Me(string access_token)
        {
            HTTPBase httpManager = new HTTPBase();
            Dictionary <string, string> queryParams = new Dictionary <string, string>();

            queryParams.Add("access_token", access_token);
            return(httpManager.Get("https://api.kaixin001.com/users/me.json", queryParams));
        }
Пример #2
0
        /// <summary>
        /// 更新token的方式请求access_token
        /// </summary>
        /// <param name="accessTokenUrl">accessToken的URL</param>
        /// <param name="apiKey">APIKEY</param>
        /// <param name="secret">Secret</param>
        /// <param name="scope">权限Scope</param>
        /// <param name="refresh_token">refreshToken,更新凭证</param>
        /// <returns>返回的数据</returns>
        public KxReturn RefreshTokenCredentials(string accessTokenUrl, string apiKey, string secret, string scope, string refresh_token)
        {
            Dictionary <string, string> queryParams = new Dictionary <string, string>();

            queryParams.Add("grant_type", "refresh_token");
            queryParams.Add("client_id", apiKey);
            queryParams.Add("client_secret", secret);
            queryParams.Add("scope", scope);
            queryParams.Add("refresh_token", refresh_token);

            HTTPBase httpBase = new HTTPBase();
            string   result   = httpBase.Post(accessTokenUrl, queryParams);

            return(new AccessToken(result));
        }
Пример #3
0
        /// <summary>
        /// AuthorizeCode 方式获取AccessToken
        /// </summary>
        /// <param name="accessTokenUrl">access_token的url</param>
        /// <param name="code">第一次请求request token的时候返回的code</param>
        /// <param name="apiKey">APIKEY</param>
        /// <param name="secret">Secret</param>
        /// <param name="redirect_uri">回调URL,必须和第一次请求request token时候一致</param>
        /// <returns>返回数据</returns>
        public KxReturn AuthorizeCodeAccessToken(string accessTokenUrl, string code, string apiKey,
                                                 string secret, string redirect_uri)
        {
            Dictionary <string, string> queryParams = new Dictionary <string, string>();

            queryParams.Add("grant_type", "authorization_code");
            queryParams.Add("code", code);
            queryParams.Add("client_id", apiKey);
            queryParams.Add("client_secret", secret);
            queryParams.Add("redirect_uri", redirect_uri);

            HTTPBase httpBase = new HTTPBase();
            string   result   = httpBase.Post(accessTokenUrl, queryParams);

            return(new AccessToken(result));
        }
Пример #4
0
        /// <summary>
        /// 用户名密码方式获取AccessToken
        /// </summary>
        /// <param name="accessTokenUrl">accessToken的url</param>
        /// <param name="userName">用户名</param>
        /// <param name="passWord">密码</param>
        /// <param name="apiKey">APIKEY</param>
        /// <param name="secret">SECRECT</param>
        /// <param name="scope">scope</param>
        /// <returns>返回的数据</returns>
        public KxReturn UserNamePassWordCredentials(string accessTokenUrl, string userName, string passWord,
                                                    string apiKey, string secret, string scope)
        {
            Dictionary <string, string> queryParams = new Dictionary <string, string>();

            queryParams.Add("grant_type", "password");
            queryParams.Add("username", userName);
            queryParams.Add("password", passWord);
            queryParams.Add("client_id", apiKey);
            queryParams.Add("client_secret", secret);
            queryParams.Add("scope", scope);

            HTTPBase httpBase = new HTTPBase();
            string   result   = httpBase.Post(accessTokenUrl, queryParams);

            return(new AccessToken(result));
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="access_token"></param>
        /// <param name="pame">信息列表,隔开</param>
        /// <returns></returns>
        public string Userinfo(string key, string access_token, string pame)
        {
            string   value = "http://api.kaixin001.com/users/me.json?fields=uid%2Cname%2Cgender%2Cbirthday&oauth_consumer_key=" + key + "&oauth_nonce=2304841ce09fbe32cf7238012967aeec&oauth_signature=Oy876Y1CB1ZOCE%2FDI0HnhIIyhks%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1334300988&oauth_token=" + access_token + "&oauth_version=1.0";
            HTTPBase http  = new HTTPBase();
            Dictionary <string, string> Dic = new Dictionary <string, string>();

            Dic.Add("fields", pame);
            Dic.Add("oauth_consumer_key", key);
            Dic.Add("oauth_nonce", "2304841ce09fbe32cf7238012967aeec&oauth_signature=Oy876Y1CB1ZOCE/DI0HnhIIyhks=&oauth_signature_method=HMAC-SHA1");
            Dic.Add("oauth_timestamp", DateTime.Now.ToString("hhssffff"));
            Dic.Add("oauth_token", "140845678_40ddd9c6ab3a9eae962e173eb614d3");
            Dic.Add("oauth_version", "1.0");
            Dic.Add("scope", "basic");

            Dic.Add("access_token", access_token);
            return(http.Get("http://api.kaixin001.com/users/me.json", Dic));
        }