Exemplo n.º 1
0
        public IEnumerable<Post> GetAllPosts(SocialIdentity identity, int count)
        {
            var accessToken = new AccessToken { Token = identity.Token, TokenSecret = identity.Secret };

            return this.client.GetAllStatus(accessToken, count).Select(
                s => new Post
                {
                    Date = TypeConverter.ConvertDate(s.CreatedAt),
                    From = new UserDetails
                    {
                        Id = s.User.Id.ToString(),
                        Name = s.User.Name,
                        ProfilePictureUrl = s.User.ProfileImageUrl,
                        ProfileUrl = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", UrlResources.WebSiteUrl, s.User.ScreenName)
                    },
                    Body = s.Text,
                    ProviderName = this.Name
                }).ToList();
        }
Exemplo n.º 2
0
        public User VerifyCredentials(AccessToken accessToken)
        {
            var url = string.Format(CultureInfo.InvariantCulture, @"{0}/account/verify_credentials.xml", RestUrl);

            using (var response = this.OAuthWebRequest(accessToken.Token, accessToken.TokenSecret, Method.GET, url, string.Empty))
            {
                return response.Content.ReadAsXmlSerializable<User>();
            }
        }
Exemplo n.º 3
0
        public void UpdateStatus(AccessToken accessToken, string status)
        {
            var url = string.Format(CultureInfo.InvariantCulture, @"{0}/statuses/update.xml", RestUrl);
            var postData = string.Format(CultureInfo.InvariantCulture, "status={0}", status);

            this.OAuthWebRequest(accessToken.Token, accessToken.TokenSecret, Method.POST, url, postData);
        }
Exemplo n.º 4
0
        public IEnumerable<Status> GetUserStatus(AccessToken accessToken, int count)
        {
            var url = string.Format(CultureInfo.InvariantCulture, @"{0}/statuses/user_timeline.xml?count={1}", RestUrl, count);

            using (var response = this.OAuthWebRequest(accessToken.Token, accessToken.TokenSecret, Method.GET, url, string.Empty))
            {
                var status = response.Content.ReadAsXmlSerializable<ArrayOfStatus>();

                return new List<Status>(status.Statuses ?? new Status[] { });
            }
        }
Exemplo n.º 5
0
        public User GetUser(AccessToken accessToken, int userId)
        {
            var url = string.Format(CultureInfo.InvariantCulture, @"{0}/users/show.xml?user_id={1}", RestUrl, userId);

            using (var response = this.OAuthWebRequest(accessToken.Token, accessToken.TokenSecret, Method.GET, url, string.Empty))
            {
                return response.Content.ReadAsXmlSerializable<User>();
            }
        }
Exemplo n.º 6
0
        public IEnumerable<Status> GetAllStatus(AccessToken accessToken, int count)
        {
            var url = string.Format(CultureInfo.InvariantCulture, @"{0}/statuses/friends_timeline.xml?count={1}", RestUrl, count);

            using (var response = this.OAuthWebRequest(accessToken.Token, accessToken.TokenSecret, Method.GET, url, string.Empty))
            {
                List<Status> statuses = null;
                try
                {
                    var status = response.Content.ReadAsXmlSerializable<ArrayOfStatus>();
                    statuses = new List<Status>(status.Statuses ?? new Status[] { });
                }
                catch (InvalidOperationException)
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        statuses = new List<Status>();
                    }
                    else
                    {
                        throw;
                    }
                }

                return statuses;
            }
        }
Exemplo n.º 7
0
 public void UpdateStatus(SocialIdentity identity, string status)
 {
     var accessToken = new AccessToken { Token = identity.Token, TokenSecret = identity.Secret };
     this.client.UpdateStatus(accessToken, OAuthHelper.UrlEncode(status));
 }
Exemplo n.º 8
0
        public UserDetails GetUserDetails(SocialIdentity identity)
        {
            var accessToken = new AccessToken { Token = identity.Token, TokenSecret = identity.Secret };

            var user = this.client.GetUser(accessToken, int.Parse(identity.Id));

            return new UserDetails
            {
                Id = user.Id.ToString(),
                Name = user.Name,
                ProfilePictureUrl = user.ProfileImageUrl,
                ProfileUrl = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", UrlResources.WebSiteUrl, user.ScreenName),
                Identity = identity
            };
        }