PHPackages                             isaacongoma/twitter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. isaacongoma/twitter

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

isaacongoma/twitter
===================

This package makes it easy to send notifications via Twitter with Laravel

v5.1.0(5y ago)010MITPHPPHP ^7.3|^8.0

Since Aug 21Pushed 4y agoCompare

[ Source](https://github.com/isaacongoma/twitter)[ Packagist](https://packagist.org/packages/isaacongoma/twitter)[ Docs](https://github.com/laravel-notification-channels/twitter)[ RSS](/packages/isaacongoma-twitter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (36)Used By (0)

Twitter notification channel for Laravel
========================================

[](#twitter-notification-channel-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3b51c856ec0700c209da5b61b3564694e97d772cbd871d03f9b9f9df65de660e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f747769747465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/twitter)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/c5c788f277a0cb841eb7f5b082aa992df7aeee7e82c3ef57257355db5bd3d202/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f747769747465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/laravel-notification-channels/twitter)[![StyleCI](https://camo.githubusercontent.com/fae1d9b40eb3780048636b7ac5b6bb8b3013e25ee5f853e30c9f1bb8774f768a/68747470733a2f2f7374796c6563692e696f2f7265706f732f36353834373338362f736869656c64)](https://styleci.io/repos/65847386)[![SensioLabsInsight](https://camo.githubusercontent.com/84c410fd9c218c577d005fd126008d1e613b962f0afbadfeac36d8f5bd5294e8/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f64653237373138322d666161342d343537362d626562622d3966323031653237393630612e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/de277182-faa4-4576-bebb-9f201e27960a)[![Quality Score](https://camo.githubusercontent.com/34b13683bb3894f624d0bfa5ea49a19f0014daa50c504c8e63f27240e91de363/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f747769747465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/twitter)[![Code Coverage](https://camo.githubusercontent.com/ccb090a66331ed57083ca48b9e37584a94582b5530144671a484a9b7421891d5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f747769747465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/twitter/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/c559b8579ed4067415fe6a3adbbee1b1710fa3b25c0e19bf06bcc77824ba8a06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f747769747465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/twitter)

This package makes it easy to send notifications using [Twitter](https://dev.twitter.com/rest/public) with Laravel. If you have an older Laravel application, you can use version 1.\*. But be aware that these versions are no longer maintained.

Contents
--------

[](#contents)

- [About](#about)
- [Installation](#installation)
- [Setting up the Twitter service](#setting-up-the-twitter-service)
- [Usage](#usage)
    - [Publish Twitter status update](#publish-twitter-status-update)
    - [Publish Twitter status update with images](#publish-twitter-status-update-with-images)
    - [Send a direct message](#send-a-direct-message)
- [Handle multiple Twitter Accounts](#handle-multiple-twitter-accounts)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

About
-----

[](#about)

This package is part of the [Laravel Notification Channels](http://laravel-notification-channels.com/) project. It provides additional Laravel Notification channels to the ones given by [Laravel](https://laravel.com/docs/master/notifications) itself.

The Twitter channel makes it possible to send out Laravel notifications as a `Twitter status update `(post on the timeline) or as a `direct message`.

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

[](#installation)

If you prefer a video, there is also [an introduction video](https://christoph-rumpel.com/2018/11/sending-laravel-notifications-via-twitter) available for you. If not, just read on.

You can install this package via composer:

```
composer require laravel-notification-channels/twitter
```

The service provider gets loaded automatically.

### Setting up the Twitter service

[](#setting-up-the-twitter-service)

You will need to [create](https://developer.twitter.com/apps/) a Twitter app to use this channel. Within this app, you will find the `keys and access tokens`. Place them inside your `.env` file. To load them, add this to your `config/services.php` file:

```
...
'twitter' => [
    'consumer_key'    => env('TWITTER_CONSUMER_KEY'),
    'consumer_secret' => env('TWITTER_CONSUMER_SECRET'),
    'access_token'    => env('TWITTER_ACCESS_TOKEN'),
    'access_secret'   => env('TWITTER_ACCESS_SECRET')
]
...
```

This will load the Twitter app data from the `.env` file. Make sure to use the same keys you have used there like `TWITTER_CONSUMER_KEY`.

Usage
-----

[](#usage)

To use this package, you need to create a notification class, like `NewsWasPublished` from the example below, in your Laravel application. Make sure to check out [Laravel's documentation](https://laravel.com/docs/master/notifications) for this process.

### Publish a Twitter status update

[](#publish-a-twitter-status-update)

```
