mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
add address lookup for pinned tweet
This commit is contained in:
parent
709c031f28
commit
624036d00c
3 changed files with 25 additions and 7 deletions
|
@ -10,7 +10,7 @@ class TwitterApi {
|
|||
static const userPath = '/2/users/by/username/';
|
||||
|
||||
static Future<TwitterUser> lookupUserByName({required String userName}) async {
|
||||
final queryParams = {'user.fields': 'description'};
|
||||
final queryParams = {'user.fields': 'description', 'expansions': 'pinned_tweet_id'};
|
||||
|
||||
final headers = {'authorization': 'Bearer $twitterBearerToken'};
|
||||
|
||||
|
@ -32,6 +32,16 @@ class TwitterApi {
|
|||
throw Exception(responseJSON['errors'][0]['detail']);
|
||||
}
|
||||
|
||||
return TwitterUser.fromJson(responseJSON['data'] as Map<String, dynamic>);
|
||||
final user = responseJSON['data'] as Map<String, dynamic>;
|
||||
|
||||
try {
|
||||
if (responseJSON['includes'] != null) {
|
||||
user['pinnedTweet'] = responseJSON['includes']['tweets'][0]['text'];
|
||||
}
|
||||
} catch (e) {
|
||||
print('responseJSON[includes][tweets][0][text] $e');
|
||||
}
|
||||
|
||||
return TwitterUser.fromJson(user);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue