diff --git a/src/Client/TwitterClient.cs b/src/Client/TwitterClient.cs index 2ac3203..b1aee42 100644 --- a/src/Client/TwitterClient.cs +++ b/src/Client/TwitterClient.cs @@ -249,6 +249,19 @@ public async Task GetAllTweets(Expression expression, TweetSearchOption return ParseArrayData(await res.Content.ReadAsStringAsync()); } + /// + /// Get the tweets liked by a user + /// + /// User ID of the user you want the linked tweets of + /// properties send with the tweet + public async Task GetLikedTweets(string userId, TweetSearchOptions options = null) + { + options ??= new(); + var res = await _httpClient.GetAsync(_baseUrl + "users/" + HttpUtility.HtmlEncode(userId) + "/liked_tweets?" + options.Build(true)); + BuildRateLimit(res.Headers, Endpoint.TweetsLiked); + return ParseArrayData(await res.Content.ReadAsStringAsync()); + } + #endregion TweetSearch #region TweetStream diff --git a/test/TestLikesByUser.cs b/test/TestLikesByUser.cs new file mode 100644 index 0000000..7052c0b --- /dev/null +++ b/test/TestLikesByUser.cs @@ -0,0 +1,25 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Linq; +using System.Threading.Tasks; +using TwitterSharp.Client; +using TwitterSharp.Request.Option; +using TwitterSharp.Response.RUser; + +namespace TwitterSharp.UnitTests +{ + [TestClass] + public class TestLikesByUser + { + [TestMethod] + public async Task GetLikesByUser() + { + var client = new TwitterClient(Environment.GetEnvironmentVariable("TWITTER_TOKEN")); + var likedTweets = await client.GetLikedTweets("1611314460399902720", new TweetSearchOptions + { + Limit = 5 + }); + Assert.IsTrue(likedTweets.Any(x => x.Id == "1636441616071180312")); + } + } +}