Skip to content

Instantly share code, notes, and snippets.

@rutvik110
Created March 24, 2022 02:59
Show Gist options
  • Save rutvik110/288e14de498f86b812f44cdd2ef1b658 to your computer and use it in GitHub Desktop.
Save rutvik110/288e14de498f86b812f44cdd2ef1b658 to your computer and use it in GitHub Desktop.
Twitter Api
// 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