Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Twitter Oembed Laravel Package

spatie/twitter-oembed

Fetch Twitter (X) tweet embed HTML via the public oEmbed API—no developer account needed. Lightweight utility for turning tweet URLs into embeddable HTML for blogs, markdown, editors, or emails, without relying on Twitter’s heavy JavaScript widget.

View on GitHub
Deep Wiki
Context7

Retrieve tweets with the Twitter oEmbed API

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A utility package to retrieve tweets with Twitter's 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

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

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. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/twitter-oembed

Usage

$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;
// "<p>Have I seen The Wire?</p>"

echo $tweet->date;
// 2019-09-16

Alternatives

  • j7mbo/twitter-api-php: A Twitter API wrapper. This returns a lot more data, but requires a developer account.
  • embed/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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope