Beispiel #1
0
        public async Task <KloutIdentity> IdentityAsync(string id, KloutIdentityKind kind = KloutIdentityKind.TwitterScreenName)
        {
            CheckKey();
            var parmeters = string.Empty;

            switch (kind)
            {
            case KloutIdentityKind.TwitterId:
            {
                parmeters = "tw/{0}";
                break;
            }

            case KloutIdentityKind.Google:
            {
                parmeters = "gp/{0}";
                break;
            }

            case KloutIdentityKind.Instagram:
            {
                parmeters = "ig/{0}";
                break;
            }

            case KloutIdentityKind.TwitterScreenName:
            {
                parmeters = "twitter?screenName={0}";
                break;
            }

            case KloutIdentityKind.KloutId:
            {
                parmeters = "klout/{0}/tw";
                break;
            }
            }
            var uri    = UriAddKey(string.Format(kloutIdentityUri + parmeters, id));
            var client = new HttpClient();
            var res    = await client.GetAsync(uri);

            if (res.IsSuccessStatusCode)
            {
                var content = await res.Content.ReadAsStringAsync();

                var identity = JsonConvert.DeserializeObject <KloutIdentity>(content);
                return(identity);
            }
            else
            {
                throw new KloutException(res.StatusCode);
            }
        }
Beispiel #2
0
        public async Task<KloutIdentity> IdentityAsync(string id, KloutIdentityKind kind = KloutIdentityKind.TwitterScreenName)
        {
            CheckKey();
						CheckIsDisposed();
						var parmeters = string.Empty;
            switch (kind)
            {
                case KloutIdentityKind.TwitterId:
                    {
                        parmeters = "tw/{0}";
                        break;
                    }
                case KloutIdentityKind.Google:
                    {
                        parmeters = "gp/{0}";
                        break;
                    }
                case KloutIdentityKind.Instagram:
                    {
                        parmeters = "ig/{0}";
                        break;
                    }
                case KloutIdentityKind.TwitterScreenName:
                    {
                        parmeters = "twitter?screenName={0}";
                        break;
                    }
                case KloutIdentityKind.KloutId:
                    {
                        parmeters = "klout/{0}/tw";
                        break;
                    }
            }
            var uri = UriAddKey(string.Format(kloutIdentityUri + parmeters, id));
            var res = await _HttpClient.GetAsync(uri).ConfigureAwait(false);
            if (res.IsSuccessStatusCode)
            {
                var content = await res.Content.ReadAsStringAsync().ConfigureAwait(false);
                var identity = JsonConvert.DeserializeObject<KloutIdentity>(content);
                return identity;
            }
            else
            {
                throw new KloutException(res.StatusCode);
            }
        }