Exemplo n.º 1
0
        public ValueTask <TwitterStatus> UpdateStatus(string text, string?replyToStatusId, string?attachmentUrl, string[]?mediaIds)
        {
            var parameters = new List <(string, string)> {
                TwitterOptions.Status(text),
                TwitterOptions.ExtendedTweetMode()
            };

            if (!string.IsNullOrEmpty(replyToStatusId))
            {
                parameters.Add(TwitterOptions.ReplyStatusId(replyToStatusId));
                parameters.Add(TwitterOptions.AutoPopulateReplyMetadata());
            }

            if (!string.IsNullOrEmpty(attachmentUrl))
            {
                parameters.Add(TwitterOptions.AttachmentUrl(attachmentUrl));
            }

            if (mediaIds?.Length > 0)
            {
                parameters.Add(TwitterOptions.MediaIds(mediaIds));
            }

            return(oAuthApiRequest
                   .PostAsync <TwitterStatus>("https://api.twitter.com/1.1/statuses/update.json", parameters));
        }
Exemplo n.º 2
0
 public ValueTask <IEnumerable <UserConnection> > GetFriendships(IEnumerable <string> ids)
 {
     return(oAuthApiRequest
            .GetAsync <IEnumerable <UserConnection> >("https://api.twitter.com/1.1/friendships/lookup.json",
                                                      new[] {
         TwitterOptions.UserIds(ids)
     }));
 }
Exemplo n.º 3
0
 public ValueTask <UploadMedia> UploadMediaFinalize(string mediaId)
 {
     return(oAuthApiRequest
            .PostAsync <UploadMedia>(UploadMediaUrl,
                                     new[] {
         TwitterOptions.Command("FINALIZE"),
         TwitterOptions.MediaId(mediaId)
     }));
 }
Exemplo n.º 4
0
 public ValueTask <UploadMedia> UploadMediaStatus(string mediaId)
 {
     return(oAuthApiRequest
            .GetAsync <UploadMedia>(UploadMediaUrl,
                                    new[] {
         TwitterOptions.Command("STATUS"),
         TwitterOptions.MediaId(mediaId)
     }));
 }
Exemplo n.º 5
0
        public async ValueTask <IEnumerable <TwitterStatus> > FavoritesTimeline()
        {
            var statuses = await oAuthApiRequest
                           .GetAsync <IEnumerable <TwitterStatus> >("https://api.twitter.com/1.1/favorites/list.json",
                                                                    TwitterOptions.Default())
                           .ConfigureAwait(false);

            return(await UpdateUserConnections(statuses).ConfigureAwait(false));
        }
Exemplo n.º 6
0
        public async ValueTask <IEnumerable <TwitterStatus> > MentionsTimeline(int count)
        {
            var statuses = await oAuthApiRequest
                           .GetAsync <IEnumerable <TwitterStatus> >("https://api.twitter.com/1.1/statuses/mentions_timeline.json",
                                                                    TwitterOptions.Default(count))
                           .ConfigureAwait(false);

            return(await UpdateUserConnections(statuses).ConfigureAwait(false));
        }
Exemplo n.º 7
0
 public ValueTask <UploadMedia> UploadMediaInit(int totalBytes, string mediaType)
 {
     return(oAuthApiRequest
            .PostAsync <UploadMedia>(UploadMediaUrl,
                                     new[] {
         TwitterOptions.Command("INIT"),
         TwitterOptions.TotalBytes(totalBytes),
         TwitterOptions.MediaType(mediaType)
     }));
 }
Exemplo n.º 8
0
 public ValueTask <TwitterStatus> GetStatus(string statusId)
 {
     return(oAuthApiRequest
            .GetAsync <TwitterStatus>("https://api.twitter.com/1.1/statuses/show.json",
                                      new[] {
         TwitterOptions.Id(statusId),
         TwitterOptions.IncludeEntities(),
         TwitterOptions.ExtendedTweetMode()
     }));
 }
Exemplo n.º 9
0
 public ValueTask <Tweet> Search(string query)
 {
     return(oAuthApiRequest
            .GetAsync <Tweet>("https://api.twitter.com/1.1/search/tweets.json",
                              new[] {
         TwitterOptions.Count(100),
         TwitterOptions.Query(query),
         TwitterOptions.IncludeEntities(),
         TwitterOptions.ExtendedTweetMode()
     }));
 }
Exemplo n.º 10
0
 public async ValueTask <IEnumerable <TwitterStatus> > GetUserTimeline(string screenName)
 {
     return(await oAuthApiRequest
            .GetAsync <IEnumerable <TwitterStatus> >("https://api.twitter.com/1.1/statuses/user_timeline.json",
                                                     new[] {
         TwitterOptions.ScreenName(screenName),
         TwitterOptions.Count(50),
         TwitterOptions.IncludeEntities(),
         TwitterOptions.IncludeRetweets(),
         TwitterOptions.ExtendedTweetMode()
     })
            .ConfigureAwait(false));
 }
Exemplo n.º 11
0
        public async ValueTask <User> UserInfo(string screenName)
        {
            var user = await oAuthApiRequest
                       .GetAsync <User>("https://api.twitter.com/1.1/users/show.json",
                                        new[] {
                TwitterOptions.IncludeEntities(),
                TwitterOptions.ExtendedTweetMode(),
                TwitterOptions.ScreenName(screenName)
            })
                       .ConfigureAwait(false);

            if (UserConnectionsService.LookupUserConnections(user.Id) is { } userConnections)
            {
                user.IsFollowing  = userConnections.IsFollowing;
                user.IsFollowedBy = userConnections.IsFollowedBy;
            }

            return(user);
        }
Exemplo n.º 12
0
 public ValueTask Unfollow(string screenName)
 {
     return(oAuthApiRequest
            .PostAsync("https://api.twitter.com/1.1/friendships/destroy.json",
                       new[] { TwitterOptions.ScreenName(screenName) }));
 }
Exemplo n.º 13
0
 public ValueTask DestroyFavorite(string statusId)
 {
     return(oAuthApiRequest
            .PostAsync("https://api.twitter.com/1.1/favorites/destroy.json",
                       new[] { TwitterOptions.Id(statusId) }));
 }