Twitter tile | laravel-dashboard | Spatie

 SPATIE

  Laravel Dashboard
====================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-dashboard](https://spatie.be/docs/laravel-dashboard/v2)  Adding-tiles  Twitter tile

 Version   v4   v3   v2   v1

 Other versions for crawler [v4](https://spatie.be/docs/laravel-dashboard/v4) [v3](https://spatie.be/docs/laravel-dashboard/v3) [v2](https://spatie.be/docs/laravel-dashboard/v2) [v1](https://spatie.be/docs/laravel-dashboard/v1)

- [ Introduction ](https://spatie.be/docs/laravel-dashboard/v2/introduction)
- [ Support us ](https://spatie.be/docs/laravel-dashboard/v2/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-dashboard/v2/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-dashboard/v2/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-dashboard/v2/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-dashboard/v2/changelog)
- [ About us ](https://spatie.be/docs/laravel-dashboard/v2/about-us)

Usage
-----

- [ Creating your first dashboard ](https://spatie.be/docs/laravel-dashboard/v2/basic-usage/creating-your-first-dashboard)
- [ Positioning tiles ](https://spatie.be/docs/laravel-dashboard/v2/basic-usage/positioning-tiles)
- [ Customizing the views ](https://spatie.be/docs/laravel-dashboard/v2/basic-usage/customizing-the-views)

Adding tiles
------------

- [ Overview ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/overview)
- [ Creating your own tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/creating-your-own-tile)
- [ Google calendar tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/google-calendar)
- [ Time and Weather tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/time-weather)
- [ Oh Dear Uptime tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/oh-dear-uptime)
- [ Twitter tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/twitter-tile)
- [ Velo tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/velo)
- [ Belgian trains tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/belgian-trains)
- [ Attendances tile ](https://spatie.be/docs/laravel-dashboard/v2/adding-tiles/attendances)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-dashboard                                                                                                                                                                                                                                    `

Twitter tile
============

###  On this page

1. [ Installation ](#content-installation)
2. [ Usage ](#content-usage)

This tile displays Twitter mentions.

![screenshot](https://spatie.be/docs/laravel-dashboard/v2/images/twitter.png)

Installation
--------------------------------------------------------------------------------------------

You can install the package via composer:

```
composer require spatie/laravel-dashboard-twitter-tile
```

In the `dashboard` config file, you must add this configuration in the `tiles` key. You can add a configuration in the `configurations` key per Twitter tile that you want to display. Any tweet that contains one of the strings in `listen_for` will be display on the dashboard.

```
// in config/dashboard.php

return [
    // ...
    'tiles' => [
          'twitter' => [
                'configurations' => [
                    'default' => [
                        'access_token' => env('TWITTER_ACCESS_TOKEN'),
                        'access_token_secret' => env('TWITTER_ACCESS_TOKEN_SECRET'),
                        'consumer_key' => env('TWITTER_CONSUMER_KEY'),
                        'consumer_secret' => env('TWITTER_CONSUMER_SECRET'),
                        'listen_for' => [
                            //
                        ],
                    ],
                ],
                'refresh_interval_in_seconds' => 5,
            ],
    ],
];
```

Under the hood this package uses [`spatie/laravel-twitter-streaming-api`](https://github.com/spatie/laravel-twitter-streaming-api). Take a look in the readme of the package to learn [how you can get the values](https://github.com/spatie/laravel-twitter-streaming-api#getting-credentials) for `access_token`, `access_token_secret`, `consumer_key`, and `consumer_key`.

Usage
-----------------------------------------------------------------------

To starting listening for incoming tweets of the configuration named `default`, you must execute this command:

```
php artisan dashboard:listen-twitter-mentions
```

This command will never end. In production should probably want to use something like Supervisord to keep this this task running and to automatically start it when your system restarts.

To start listening for tweets of another configuration, simply add the name of the configuration as an arugment.

```
php artisan dashboard:listen-twitter-mentions alternate-configuration-name
```

In your dashboard view you use the `livewire:twitter-tile` component to display tweets of the default configuration.

```

```

To display tweets of another configuration, pass the name of the configuration to the `configuration-name` prop.

```

```

### Customizing the view

If you want to customize the view used to render this tile, run this command:

```
php artisan vendor:publish --provider="Spatie\TwitterTile\TwitterTileServiceProvider" --tag="dashboard-twitter-tile-views"
```
