Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spatie/twitter-oembed
Retrieve tweets with the Twitter oEmbed API
https://github.com/spatie/twitter-oembed
api embd php twitter
Last synced: 2 months ago
JSON representation
Retrieve tweets with the Twitter oEmbed API
- Host: GitHub
- URL: https://github.com/spatie/twitter-oembed
- Owner: spatie
- License: mit
- Created: 2021-07-12T10:59:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T14:43:13.000Z (almost 3 years ago)
- Last Synced: 2024-10-05T11:17:46.968Z (3 months ago)
- Topics: api, embd, php, twitter
- Language: PHP
- Homepage: https://spatie.be/open-source
- Size: 21.5 KB
- Stars: 8
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://supportukrainenow.org)
# Retrieve tweets with the Twitter oEmbed API
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/twitter-oembed.svg?style=flat-square)](https://packagist.org/packages/spatie/twitter-oembed)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/spatie/twitter-oembed/run-tests?label=tests)](https://github.com/spatie/twitter-oembed/actions?query=workflow%3ATests+branch%3Amaster)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/spatie/twitter-oembed/Check%20&%20fix%20styling?label=code%20style)](https://github.com/spatie/twitter-oembed/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/twitter-oembed.svg?style=flat-square)](https://packagist.org/packages/spatie/twitter-oembed)A utility package to retrieve tweets with Twitter's [oEmbed API](https://developer.twitter.com/en/docs/twitter-for-websites/oembed-api). The main benefit of Twitter's oEmbed API is that it's public. You don't need to set up a developer account to get started, but the data in the response is minimal.
This package is meant to set the stage for tools that embed Tweets. For example, a markdown plugin that embeds tweets as static HTML so your blog doesn't need a bloated JavaScript widget. Or a rich text editor plugin for your email platform so tweets can be embedded in newsletters, like Substack does.
It's still in an experimental stage, I'm not sure what direction this is going to go yet. I don't think it's valuable enough as long as it doesn't support displaying basic data like an image or quoted tweet, which the oEmbed API doesn't return by default.
## Support us
[](https://spatie.be/github-ad-click/twitter-oembed)
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
## Installation
You can install the package via composer:
```bash
composer require spatie/twitter-oembed
```## Usage
```php
$tweet = (new TwitterOEmbed())->embed(
'https://twitter.com/AoDespair/status/1173718972103090177'
);echo $tweet->url;
// "https://twitter.com/AoDespair/status/1173718972103090177"echo $tweet->name;
// "David Simon"echo $tweet->username;
// "@AoDespair"echo $tweet->html;
// "Have I seen The Wire?
"echo $tweet->date;
// 2019-09-16
```## Alternatives
- **[j7mbo/twitter-api-php](https://github.com/J7mbo/twitter-api-php):** A Twitter API wrapper. This returns a lot more data, but requires a developer account.
- **[embed/embed](https://github.com/oscarotero/Embed):** A generic oEmbed package. This supports retrieving oEmbed data from any source, like YouTube or Wikipedia. `spatie/twitter-oembed` aims to add Twitter specific features like parsing the tweet's date and author metadata.## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.