FeedHive / twitter-api-client

A user-friendly Node.js / JavaScript client library for interacting with the Twitter API.
MIT License
948 stars 84 forks source link

GET statuses/oembed support #59

Closed carlitosz closed 3 years ago

carlitosz commented 3 years ago

What does this pull request introduce? Please describe
Adding support for the statuses/oembed endpoint described in my issue #58

How did you verify that your changes work as expected? Please describe

Example
Please describe how we can try out your changes

  1. Create new file
  2. Instantiate client
  3. Call the tweets.statusesOembed method passing the required parameter url
  4. Check response

Screenshots
If applicable, add screenshots to demonstrate your changes.

My script:

async getEmbeddableTweet(url) {
      try {
          const res = await this.client.tweets.statusesOembed({ url });

          return res;
      } catch (e) {
          throw e;
      }
  }

Example output:

{
    "url": "https://twitter.com/Cristiano/status/1363984962270158850",
    "author_name": "Cristiano Ronaldo",
    "author_url": "https://twitter.com/Cristiano",
    "html": "<blockquote class=\"twitter-tweet\"><p lang=\"it\" dir=\"ltr\">Vittoria importante! Felice di aver dato il mio contributo! Avanti così ragazzi! 🚀 🏳️🏴💪🏽 <a href=\"https://t.co/FC9PCpK7bh\">pic.twitter.com/FC9PCpK7bh</a></p>&mdash; Cristiano Ronaldo (@Cristiano) <a href=\"https://twitter.com/Cristiano/status/1363984962270158850?ref_src=twsrc%5Etfw\">February 22, 2021</a></blockquote>\n<script async src=\"https://platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>\n",
    "width": 550,
    "height": null,
    "type": "rich",
    "cache_age": "3153600000",
    "provider_name": "Twitter",
    "provider_url": "https://twitter.com",
    "version": "1.0"
}

Version
Which version is your changes included in?

PR Checklist Please verify that you: