示例#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
                   .Post <TwitterStatus>("https://api.twitter.com/1.1/statuses/update.json", parameters));
        }
示例#2
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()
     }));
 }
示例#3
0
 public ValueTask <User> UserInfo(string screenName)
 {
     return(oAuthApiRequest
            .Get <User>("https://api.twitter.com/1.1/users/show.json",
                        new[]
     {
         TwitterOptions.IncludeEntities(),
         TwitterOptions.ExtendedTweetMode(),
         TwitterOptions.ScreenName(screenName)
     }));
 }
示例#4
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()
     }));
 }
示例#5
0
 public ValueTask <IEnumerable <TwitterStatus> > GetUserTimeline(string screenName)
 {
     return(oAuthApiRequest
            .GetAsync <IEnumerable <TwitterStatus> >("https://api.twitter.com/1.1/statuses/user_timeline.json",
                                                     new[] {
         TwitterOptions.ScreenName(screenName),
         TwitterOptions.Count(25),
         TwitterOptions.IncludeEntities(),
         TwitterOptions.IncludeRetweets(),
         TwitterOptions.ExtendedTweetMode()
     }));
 }
示例#6
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);

            var userConnections = UserConnectionsService.LookupUserConnections(user.Id);

            user.IsFollowing  = userConnections?.IsFollowing ?? false;
            user.IsFollowedBy = userConnections?.IsFollowedBy ?? false;
            return(user);
        }