Broadcasting the latest tweets with following tags: #laravel, #php, #javascript, #vuejs, #reactjs, @reactjs, @vuejs, @laravelphp, @laravelnews, @LaravelLinks, @LaravelLivewire, @Alpine_JS, @inertiajs, #inertiajs, @tailwindcss, #tailwindcss.
Powered by Laravel Wave.
Default Echo setup in resources/js/bootstrap.js:
import Echo from "laravel-echo";
import { WaveConnector } from "laravel-wave";
window.Echo = new Echo({ broadcaster: WaveConnector });
New tweets listener in resources/js/Components/TweetList:
import { ref } from "vue";
const tweets = ref([]);
window.Echo.channel("twitter-stream").listen("NewTweet", (e) =>
tweets.value.unshift(e)
);
Broadcasting a simple public event NewTweet fires.
composer install
npm install
npm run dev
Fill twitter API credentials in .env file.
TWITTER_HANDLE=
TWITTER_API_KEY=
TWITTER_API_SECRET_KEY=
TWITTER_BEARER_TOKEN=
Run stream listener:
php artisan twitter:stream