Created
March 24, 2022 02:59
-
-
Save rutvik110/288e14de498f86b812f44cdd2ef1b658 to your computer and use it in GitHub Desktop.
Twitter Api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get Tweet info along with user info if needed by expanding to user | |
final http.Response responce = await http.get( | |
Uri.parse( | |
'https://api.twitter.com/2/tweets?ids=$tweetId&expansions=author_id&user.fields=name,profile_image_url', | |
), | |
headers: { | |
'Authorization': 'Bearer ${Bearer Token}', | |
}, | |
); | |
// Get Embed Html for a Tweet | |
@override | |
Future<String> fetchTweetEmbedHtml(EmbedTweetParam param) async { | |
final http.Response responce = await http.get( | |
Uri.parse( | |
'https://publish.twitter.com/oembed?url=https://twitter.com/Interior/status/${param.tweetId}&hide_media=${param.showMedia}', | |
), | |
); | |
final Map<String, dynamic> data = | |
jsonDecode(responce.body) as Map<String, dynamic>; | |
return data['html'] as String; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment