Add initial support for Twitter V2 Timelines#1144
Add initial support for Twitter V2 Timelines#1144josiasal wants to merge 1 commit intolinvi:masterfrom
Conversation
There was a problem hiding this comment.
This looks good overall.
One thing I noticed is that if you call the iterator twice, when the pagination_token is added there is an Exception happening for me.
I don't see how your code could be the reason of this but I noticed it.
eason : Unauthorized
Details : {"errors":[{"message":"Could not authenticate you","code":32}]}
(0)
Code : 401
Date : 11/12/2021 00:31:00 +00:00
URL : https://api.twitter.com/2/users/1577389800/tweets?expansions=attachments.poll_ids%2Cattachments.media_keys%2Cauthor_id%2Centities.mentions.username%2Cgeo.place_id%2Cin_reply_to_user_id%2Creferenced_tweets.id%2Creferenced_tweets.id.author_id&media.fields=duration_ms%2Cheight%2Cmedia_key%2Cpreview_image_url%2Ctype%2Curl%2Cwidth&place.fields=contained_within%2Ccountry%2Ccountry_code%2Cfull_name%2Cgeo%2Cid%2Cname%2Cplace_type&poll.fields=duration_minutes%2Cend_datetime%2Cid%2Coptions%2Cvoting_status&tweet.fields=attachments%2Cauthor_id%2Ccontext_annotations%2Cconversation_id%2Ccreated_at%2Centities%2Cgeo%2Cid%2Cin_reply_to_user_id%2Clang%2Cpossibly_sensitive%2Creferenced_tweets%2Csource%2Ctext%2Cwithheld%2Cpublic_metrics&user.fields=created_at%2Cdescription%2Centities%2Cid%2Clocation%2Cname%2Cpinned_tweet_id%2Cprofile_image_url%2Cprotected%2Curl%2Cusername%2Cverified%2Cwithheld%2Cpublic_metrics&pagination_token=7140dibdnow9c7btw3q1g9zhsd4179i4fyr6n1ksgau5u
Twitter documentation description : Unauthorized - Authentication credentials were missing or incorrect.
Do you happen to receive the same exception? Here is repro code:
var timelineIterator = client.TimelinesV2.GetUserTweetsTimelineIterator(new GetTimelinesV2Parameters("1577389800"));
var page1 = await timelineIterator.NextPageAsync();
// Error happens next line
var page2 = await timelineIterator.NextPageAsync();
I opened a request on twittercommunity: https://twittercommunity.com/t/401-on-timeline-request-with-pagination-token/162027
| // IBaseTweetsV2Parameters | ||
| query.AddParameterToQuery("expansions", parameters.Expansions); | ||
| query.AddParameterToQuery("media.fields", parameters.MediaFields); | ||
| query.AddParameterToQuery("place.fields", parameters.PlaceFields); | ||
| query.AddParameterToQuery("poll.fields", parameters.PollFields); | ||
| query.AddParameterToQuery("tweet.fields", parameters.TweetFields); | ||
| query.AddParameterToQuery("user.fields", parameters.UserFields); |
There was a problem hiding this comment.
Replace with:
_tweetsV2QueryGenerator.AddTweetFieldsParameters(parameters, query);
| { | ||
| public class TimelinesV2QueryGenerator : ITimelinesV2QueryGenerator | ||
| { | ||
| public string GetTimelineQuery(IGetTimelinesV2Parameters parameters) |
There was a problem hiding this comment.
Add
private readonly ITweetsV2QueryGenerator _tweetsV2QueryGenerator;
public TimelinesV2QueryGenerator(ITweetsV2QueryGenerator tweetsV2QueryGenerator)
{
_tweetsV2QueryGenerator = tweetsV2QueryGenerator;
}
|
|
||
| namespace Tweetinvi.Client.V2 | ||
| { | ||
| public interface ITimelinesV2Client |
There was a problem hiding this comment.
We should include additional methods here to provide access directly to a single request and not necessarily the iterator.
This is similar to
Task<TimelinesV2Response> GetUserTweetsTimeline(string userId);
Task<TimelinesV2Response> GetUserTweetsTimeline(IGetTimelinesV2Parameters parameters);
// ...
Implementation example:
var iterator = GetUserTweetsTimelineIterator(parameters);
return (await iterator.NextPageAsync().ConfigureAwait(false)).ToArray();
I guess this can be done in another commit.
There was a problem hiding this comment.
Ok. Let's work on this in the next commit.
| /// This object contains information about the number of users | ||
| /// returned in the current request and pagination details. |
There was a problem hiding this comment.
This is actually an error of description on the Twitter API website I think. Lets change this to
/// This object contains information about the Timeline Tweets
/// returned in the current request and pagination details.
|
In a second commit, it will be good to add the documentation for Timelines. |
834ff6a to
0e50453
Compare
No description provided.