Closed shinobi-art closed 1 year ago
Thanks for your contribution! :)
Hi @shinobi-art , thanks for your feedback!
I think, this is an official Twitter spec change, previously only App-Only tokens could be used.
Are you interested in this Issue pull request? The following modification allows the use of tokens other than AppOnly :)
From:
@override
Future<TwitterResponse<List<TweetData>, TweetMeta>> searchRecent({
required String query,
int? maxResults,
String? nextToken,
SortOrder? sortOrder,
DateTime? startTime,
DateTime? endTime,
String? sinceTweetId,
String? untilTweetId,
List<TweetExpansion>? expansions,
List<TweetField>? tweetFields,
List<UserField>? userFields,
List<PlaceField>? placeFields,
List<PollField>? pollFields,
List<MediaField>? mediaFields,
ForwardPaging<List<TweetData>, TweetMeta>? paging,
}) async =>
await super.executeForwardPaginationIfNecessary(
UserContext.appOnly,
'/2/tweets/search/recent', // Change Here
{
'query': query,
'max_results': maxResults,
'next_token': nextToken,
'sort_order': sortOrder?.name,
'start_time': startTime,
'end_time': endTime,
'since_id': sinceTweetId,
'until_id': untilTweetId,
'expansions': expansions,
'tweet.fields': tweetFields,
'user.fields': userFields,
'place.fields': placeFields,
'poll.fields': pollFields,
'media.fields': mediaFields,
},
paging: paging,
dataBuilder: TweetData.fromJson,
metaBuilder: TweetMeta.fromJson,
);
To:
@override
Future<TwitterResponse<List<TweetData>, TweetMeta>> searchRecent({
required String query,
int? maxResults,
String? nextToken,
SortOrder? sortOrder,
DateTime? startTime,
DateTime? endTime,
String? sinceTweetId,
String? untilTweetId,
List<TweetExpansion>? expansions,
List<TweetField>? tweetFields,
List<UserField>? userFields,
List<PlaceField>? placeFields,
List<PollField>? pollFields,
List<MediaField>? mediaFields,
ForwardPaging<List<TweetData>, TweetMeta>? paging,
}) async =>
await super.executeForwardPaginationIfNecessary(
+ UserContext.oauth2OrOAuth1,
'/2/tweets/search/recent',
{
'query': query,
'max_results': maxResults,
'next_token': nextToken,
'sort_order': sortOrder?.name,
'start_time': startTime,
'end_time': endTime,
'since_id': sinceTweetId,
'until_id': untilTweetId,
'expansions': expansions,
'tweet.fields': tweetFields,
'user.fields': userFields,
'place.fields': placeFields,
'poll.fields': pollFields,
'media.fields': mediaFields,
},
paging: paging,
dataBuilder: TweetData.fromJson,
metaBuilder: TweetMeta.fromJson,
);
@all-contributors please add @shinobi-art for bug, question
@myConsciousness
I've put up a pull request to add @shinobi-art! :tada:
Hi @myConsciousness , thank you for feedback me soon! Could you please make a pull request to fix this issue, and release in the next version of the lib(4.7.2). Thanks,
Hello, Thanks for building an amazing lib,
I have check https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent The official Twitter Developer page say this api support both authentication methods:
But when I use your lib, call
searchRecent
api, it say 'Only AppOnly token is allowed on this endpoint.'.Could you please check the api again? Thanks.