/twitter-oembed-api

No longer maintained.

Primary LanguageDartBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

twitter_oembed_api

The Easiest Way to Use the Twitter oEmbed API in Dart and Flutter App 🐦


GitHub Sponsor GitHub Sponsor

pub package Dart SDK Version Test Analyzer Issues Pull Requests Stars Contributors Code size Last Commits License Contributor Covenant


1. Guide 🌎

This library provides the easiest way to use the Twitter oEmbed API in Dart and Flutter apps.

Show some ❀️ and star the repo to support the project.

1.1. Features πŸ’Ž

1.2. Getting Started ⚑

1.2.1. Install Library

With Dart:

 dart pub add twitter_oembed_api

With Flutter:

 flutter pub add twitter_oembed_api

1.2.2. Import

import 'package:twitter_oembed_api/twitter_oembed_api';

1.2.3. Implementation

import 'package:twitter_oembed_api/twitter_oembed_api.dart';

Future<void> main() async {
  final twitterApi = TwitterOEmbedApi();

  try {
    // You can get the embedded tweet by specifying the tweet ID.
    final embeddedTweet = await twitterApi.publishEmbeddedTweet(
      screenName: 'Interior',
      tweetId: '507185938620219395',
      maxWidth: 550,
      align: ContentAlign.center,
    );

    print(embeddedTweet.html);

    // You can get the embedded timeline by specifying the screen name.
    // Or the embedded timeline of the list.
    final embeddedTimeline = await twitterApi.publishEmbeddedTimeline(
      screenName: 'TwitterDev',
      theme: ContentTheme.dark,
    );

    print(embeddedTimeline.html);
  } on TwitterOEmbedException catch (e) {
    print(e);
  }
}

1.3. Supported Features πŸ‘€

Method
publishEmbeddedTweet

Embedded Tweets bring your pick of content from Twitter into your website articles. An embedded tweet includes photos, video and cards media created for display on Twitter, and can even stream live video from Periscope. All aspects of Twitter’s display requirements are handled for you by using our tools; author attribution, Tweet actions, hashtags, mentions, and other key components of the Twitter experience.

The returned HTML snippet will be automatically recognized as an embedded tweet when Twitter's widget JavaScript is included on the page.

With this feature, you can easily show the following beautiful tweet view in the Flutter app.

embedded tweet

Method
publishEmbeddedTimeline

Embedded timelines are an easy way to embed Tweets on your website in a compact, linear view. Choose between a profile timeline to get the latest Tweets from a Twitter account, or a List timeline containing a curated list of Twitter accounts. An embedded timeline consists of two parts: including an embed code that links your webpage to the timeline on Twitter.com, and the Twitter for Websites JavaScript to transform the link into a fully-rendered timeline.

With this feature, you can easily show the following beautiful timeline view in the Flutter app.

embedded timeline

1.4. Contribution πŸ†

If you would like to contribute to twitter_oembed_api, please create an issue or create a Pull Request.

There are many ways to contribute to the OSS. For example, the following subjects can be considered:

  • There are request parameters or response fields that are not implemented.
  • Documentation is outdated or incomplete.
  • Have a better way or idea to achieve the functionality.
  • etc...

You can see more details from resources below:

Or you can create a discussion if you like.

Feel free to join this development, diverse opinions make software better!

1.5. Related Libraries πŸ“’

We also provide the following powerful libraries related to Twitter! 🐦

Library Description Links
twitter_api_v2 The easiest way to using Twitter API v2.0 with Dart and Flutter. Strong support for all v2.0 endpoints. GitHub
Pub.dev
twitter_oauth2_pkce This is the easiest way to obtain a Twitter access token using the OAuth 2.0 PKCE method. GitHub
Pub.dev
twitter_cards This library provides the easiest way to integrate Twitter Cards into your Flutter Web app. GitHub
Pub.dev

1.6. License πŸ”‘

All resources of twitter_oembed_api is provided under the BSD-3 license.

Copyright 2022 Kato Shinya. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided the conditions.

Note
License notices in the source are strictly validated based on .github/header-checker-lint.yml. Please check header-checker-lint.yml for the permitted standards.

1.7. More Information 🧐

twitter_oembed_api was designed and implemented by Kato Shinya (@myConsciousness).