Giter Site home page Giter Site logo

laravel-notification-channels / twitter Goto Github PK

View Code? Open in Web Editor NEW
169.0 11.0 45.0 166 KB

Twitter Notifications Channel for Laravel

Home Page: http://laravel-notification-channels.com

License: MIT License

PHP 100.00%
laravel laravel-package laravel-notification-channels

twitter's Introduction

image

Twitter notification channel for Laravel

Latest Version on Packagist Software License StyleCI Quality Score Code Coverage Total Downloads

This package makes it easy to send Laravel notifications using Twitter. (Laravel 8+)

PS: v8 now uses the new Twitter API V2. Please read the upgrade guide for your app here.

Contents

About

This package is part of the Laravel Notification Channels project. It provides additional Laravel Notification channels to the ones given by Laravel itself.

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

Installation

If you prefer a video, there is also an introduction video 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.

Twitter App & Credentials

You will need to create a Twitter app to use this channel. Within this app, you will find the keys and access tokens.

Your Twitter app must be within a project. Also, make sure to activate the user authentication settings:

image

After that, you have to regenerate your access token and secret. If done correctly, you should see the right permissions for your access tokens:

image

Make sure to copy the right credentials and place them inside your .env file.

TWITTER_CONSUMER_KEY=your-consumer-key
TWITTER_CONSUMER_SECRET=your-consumer-secret
TWITTER_ACCESS_TOKEN=your-accesss_token
TWITTER_ACCESS_SECRET=your-access-token-secret
image

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')
]
...

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 for this process.

Publish a Twitter status update

<?php

use Illuminate\Notifications\Notification;
use NotificationChannels\Twitter\TwitterChannel;
use NotificationChannels\Twitter\TwitterMessage;
use NotificationChannels\Twitter\TwitterStatusUpdate;

class NewsWasPublished extends Notification
{
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [TwitterChannel::class];
    }

    public function toTwitter(mixed $notifiable): TwitterMessage
    {
        return new TwitterStatusUpdate('Laravel notifications are awesome!');
    }
}

Take a closer look at the toTwitter method. Here, we define what kind of Twitter message we want to trigger. In this case, it is a status update message, which is just a new message in your timeline.

public function toTwitter(mixed $notifiable): TwitterMessage
{
    return new TwitterStatusUpdate('Laravel notifications are awesome!');
}

Publish Twitter status update with images

It is possible to publish images with your status update too. You have to pass the image path to the withImage method.

public function toTwitter(mixed $notifiable): TwitterMessage
{
    return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withImage('marcel.png');
}

If you want to use multiple images, just pass an array of paths.

return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withImage([
    public_path('marcel.png'),
    public_path('mohamed.png')
]);

Publish Twitter status update with videos

It is possible to publish videos with your status update too. You have to pass the video path to the withVideo method.

public function toTwitter(mixed $notifiable): TwitterMessage
{
    return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withVideo('video.mp4');
}

If you want to use multiple videos, just pass an array of paths.

return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withVideo([
    public_path('video1.mp4'),
    public_path('video.gif')
]);

Publish Twitter status update with both images and videos

It is also possible to publish both images and videos with your status by using a mixture of the two methods.

return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withVideo([
    public_path('video1.mp4'),
    public_path('video.gif')
])->withImage([
    public_path('marcel.png'),
    public_path('mohamed.png')
]);

Publish a Twitter status update in reply to another tweet

Additionally, you can publish a status update in reply to another tweet. This is possible by using the inReplyTo method.

public function toTwitter(mixed $notifiable): TwitterMessage
{
    return (new TwitterStatusUpdate('@christophrumpel Laravel notifications are awesome!'))->inReplyTo(123);
}

Note that the reply status ID will be ignored if you omit the author of the original tweet, according to Twitter docs.

Send a direct message (NOT working with the FREE Twitter API plan!)

To send a Twitter direct message to a specific user, you will need the TwitterDirectMessage class. Provide the Twitter user handler as the first parameter and the message as the second one.

public function toTwitter(mixed $notifiable): TwitterMessage
{
     return new TwitterDirectMessage('marcelpociot', 'Hey Marcel, it was nice meeting you at the Laracon.');
}

You can also provide the user ID instead of the screen name. This would prevent an extra Twitter API call. Make sure to pass it as an integer when you do.

public function toTwitter(mixed $notifiable): TwitterMessage
{
     return new TwitterDirectMessage(12345, 'Hey Marcel, it was nice meeting you at the Laracon.');
}

Handle multiple Twitter Accounts

There might be cases where you need to handle multiple Twitter accounts. This means you need to be able to change the provided keys and tokens of your Twitter app. Luckily, Laravel can help you here. In your notifiable model, you can define the routeNotifiactionForTwitter method. Here you can override the provided settings.

public function routeNotificationForTwitter($notification)
{
   return [
      'TWITTER_CONSUMER_KEY',
      'TWITTER_CONSUMER_SECRET',
      'TWITTER_ACCESS_TOKEN',
      'TWITTER_ACCESS_SECRET',
   ];
}

Changelog

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

Testing

$ composer test

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

twitter's People

Contributors

ahmedash95 avatar berkayoztunc avatar bmitch avatar carusogabriel avatar christophrumpel avatar driesvints avatar dwightwatson avatar enniel avatar freekmurze avatar gms8994 avatar gpluess avatar hazaveh avatar jeffwa avatar jono20201 avatar laravel-shift avatar leganz avatar michaloravec avatar mohamedsabil83 avatar mpociot avatar nathangiesbrecht avatar nelwhix avatar omerbaflah avatar otsch avatar ousid avatar samuelnitsche avatar shutupflanders avatar synchro avatar thinkverse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitter's Issues

PHP7 Required

In TwitterStatusUpdate constructor you're type hinting message to a string which requires php 7 but in your composer you have 5.6.4

Not working media

Hi,

there is issue with sending media.

As you can see in the code there is a comment:

// api V2 does not support sending media yet, so I wait till after sending media to switch api version

That was added within this PR exactly 15. July 2023.

But as of version 6.0 abraham/twitteroauth which was released on July 24, 2023, the default twitter api version is 2.

This means it will be necessary to set version 1.1 using $this->twitter->setApiVersion('1.1'); at the beginning of send method in TwitterChannel as you can see on the image below:

image

Twitter free plan no longer supports direct messaging, logic change required

Hi, I recently posted this, but I think it won't initially be possible resolve as the free plan only supports posting tweets, and not running queries.

I wonder whether the logic can be changed to post a tweet via a username, or some workaround implemented for

/**
     * Get Twitter direct message receiver.
     *
     * @return string|mixed
     *
     * @throws CouldNotSendNotification
     */
    public function getReceiver(TwitterOAuth $twitter): mixed
    {
        if (is_int($this->to)) {
            return $this->to;
        }

        $user = $twitter->get('users/show', [
            'screen_name' => $this->to,
            'include_user_entities' => false,
            'skip_status' => true,
        ]);

        if ($twitter->getLastHttpCode() === 404) {
            throw CouldNotSendNotification::userWasNotFound($twitter->getLastBody());
        }

        return $user->id;
    }

As I need to utilise the approach of sending a message to someone's account via their twitter handle

Multiple Twitter Accounts

First up, awesome package! ๐Ÿ™Œ

I've hit a use case where I want to be able to switch the Twitter account my app posts from. Super quick, high level explanation, but my app has regions and each region has its own Twitter account. I'm looking/hoping to have multiple entries in my env file corresponding to each twitter account and then being able to specify which to post to.

Bad URL: unable to shorten

First of all, thanks for this amazing package. I've been using it for quite some time now to send twitter DMs. My message content always contains one or more URLs in it. These URLs could be to other tweets or external websites. I'm facing an issue of Bad URL: unable to shorten : (Already shorten URL) exception from time to time and I was wondering if there is any way to get around shortening these types of links?

Thanks.

Code review

Let me know when you're done with the code, tests and readme. I'll do a little code review, register the package on Packagist and start some automatic code quality checks.

Array and string offset access syntax with curly braces is deprecated on PHP 7.4

Hello,

As required by composer.json, "abraham/twitteroauth" is used in its 0.9.2 version, which accesses arrays with curly braces, a feature deprecated since PHP 7.4.

https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.array-string-access-curly-brace

Array and string offset access using curly braces
The array and string offset access syntax using curly braces is deprecated. Use $var[$idx] instead of $var{$idx}.

It has been fixed with this commit.
You should bump abraham/twitteroauth dependency to fix the usage of this package with PHP 7.4

Thank you

mediaIds array or collection?

Hello,

I am attaching media not from URL, but by id
Like:

$tweet = new TwitterStatusUpdate($text);
$tweet->imageIds = collect([$twitter_media_id]);

But it says it should be an array, in the var declaration.

    /**
     * @var  array
     */
    public $imageIds;

So probably this should be changed to implode(',', $this->imageIds);
or change to Collection?


if ($this->imageIds) {
            $body['media_ids'] = $this->imageIds->implode(',');
        }

thanks

Markup links

As an extension of this issue, #59 (comment), I wonder if it is possible to send a markup link like:

<a href="http://www.myexample.com">My Example</a>

giving My Example as result.

I've tried nl2br, htmlentities,htmlspecialchars ... but no luck.

Conflict - Cannot install

Any idea how to resolve this ? I am still on Laravel 7.xx

composer require laravel-notification-channels/twitter
Using version ^5.0 for laravel-notification-channels/twitter
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel-notification-channels/twitter v5.0.1
    - Conclusion: remove laravel/framework v7.28.4
    - Installation request for laravel-notification-channels/twitter ^5.0 -> satisfiable by laravel-notification-channels/twitter[v5.0.0, v5.0.1].
    - Conclusion: don't install laravel/framework v7.28.4
    - laravel-notification-channels/twitter v5.0.0 requires illuminate/notifications ^8.0 -> satisfiable by laravel/framework[8.x-dev], illuminate/notifications[8.x-dev, v8.0.0, v8.0.1, v8.0.2, v8.0.3, v8.0.4, v8.1.0, v8.10.0, v8.2.0, v8.3.0, v8.4.0, v8.5.0, v8.6.0, v8.7.0, v8.7.1, v8.8.0, v8.9.0].
    - Can only install one of: laravel/framework[8.x-dev, v7.28.4].
    - don't install illuminate/notifications 8.x-dev|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.0.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.0.1|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.0.2|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.0.3|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.0.4|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.1.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.10.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.2.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.3.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.4.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.5.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.6.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.7.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.7.1|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.8.0|don't install laravel/framework v7.28.4
    - don't install illuminate/notifications v8.9.0|don't install laravel/framework v7.28.4
    - Installation request for laravel/framework (locked at v7.28.4, required as ^7.0) -> satisfiable by laravel/framework[v7.28.4].


Installation failed, reverting ./composer.json to its original content.

Returning Twitter class as string in via method (TwitterChannel:::class)

๐Ÿ‘‹ Opening another issue here regarding the implementation of the Twitter channel in the via method for my notification class. Notifications are now able to send if I simply just [TwitterChannel::class] in my via method, but my application allows users to effectively have "notification types" and as such are saved onto my User model and look like this:

{
    "dns": {
        "changed": ["nexmo", "database", "mail", "twitter"]
    },
    "ssl": {
        "expiry": ["nexmo", "mail"]
    },
    "domains": {
        "expiry": ["nexmo", "database"]
    },
    "monitors": {
        "up": ["database", "mail"],
        "down": ["database", "mail", "twitter"]
    }
}

This presents the challenge of including Twitter since I'd ideally just like to include a twitter string in my notification channel since this is ultimately rendered into the view as checkboxes.

When I try to use twitter as a string, unlike the Nexmo, Database, Slack and Mail drivers, the Twitter notification channel throws an error:

InvalidArgumentException: Driver [twitter] not supported.

Each notification is my application links up to one of my via objects, for example: my monitor MonitorDown notification links up to monitors->down as JSON, I have other business logic that I need to perform to, such as being able to dynamically push or remove Twitter from my notification preferences.

Is there a simple workaround or modification I can add so that the TwitterChannel::class is initialised and then if there's a twitter string in my notification preferences for that notification it then runs since we have the toTwitter method?

/**
 * Get the notification's delivery channels.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    $preferences = json_decode($notifiable->notification_preferences);

    if (!$notifiable->is_subscribed) {
        $preferences->monitors->down = array_merge(array_diff($preferences->monitors->down, [
            'nexmo', 'discord', 'twitter'
        ]));
    }

    // desired outcome
    return ['twitter'];

    // must come from here
    return $preferences->monitors->down;
}

P.S: I have several other notifications I need to apply this to

spacing content displayed on twitter

return (new TwitterStatusUpdate($blog->name .' https://google.com/'. $blog->slug))->withImage($image);

i'm using this to display title content, link & image on twitter however the content & title seem to not space apart :/ how would i do this

Send Tweets now locked behind V2; update needed.

Twitter appears to have forced current V1.1 apps to migrate to V2 this morning, thus causing this to break, including just sending text-only tweets.

Without any changes, we received the following error from Twitter:

"Couldn't post notification. Response: You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product".

This appears to be because this package only utilizes the V1.1 API endpoints. As other issues have been made relating to this, could this finally be updated? Otherwise, the package should be archived soon.

Even after migrating to V2 (after initially receiving this error), we are still experiencing the same issue.

Thank you, as always.

Laravel 5.5 support

Hello dear contributors,
is it possible to support Laravel 5.5? I will try it now with an override.
Best regards from Munich

Bug: defined property: stdClass::$id

๐Ÿ‘‹ Hi,

Just reaching out as I've identified a problem with the getReceiver function, firstly, not quite sure why I'm getting the error in the first place, I'm using v8.0.0 of the package, getting the error:

ErrorException: Undefined property: stdClass::$id in /var/www/domain-monitor-api/vendor/laravel-notification-channels/twitter/src/TwitterDirectMessage.php:45

Presumably the error handling of the $user->id here needs to be more robust?

/**
 * Get Twitter direct message receiver.
 *
 * @return string|mixed
 *
 * @throws CouldNotSendNotification
 */
public function getReceiver(TwitterOAuth $twitter): mixed
{
    if (is_int($this->to)) {
        return $this->to;
    }

    $user = $twitter->get('users/show', [
        'screen_name' => $this->to,
        'include_user_entities' => false,
        'skip_status' => true,
    ]);

    if ($twitter->getLastHttpCode() === 404) {
        throw CouldNotSendNotification::userWasNotFound($twitter->getLastBody());
    }

    return $user->id;
}

Support for Laravel 5.7?

Hi guys, thanks for this great package.

I'm running into an error when upgrading to Laravel 5.7.
Is it possible to fix it in Packagist so we can pull?

Thanks

Send notification to user

I think twitter notification must be for chat messages also , something like

return new TwitterMessage('ahmedash95','you have a notification in our app');

BTW, i could make a PR for this implementation

Undefined property: stdClass::$media_id_string

Hi,

when i try to run my code i get

Undefined property: stdClass::$media_id_string

on

 $post->notify(new \App\Notifications\PostPublished($post));

here is my notification function:

public function toTwitter($post)
    {
        $title = $post->title;
        $slug = $post->slug;
        $image = $post->image;
        return (new TwitterStatusUpdate($title ."\n https://domain.co/blog/". $slug))->withImage('http://domain.co/storage/images/'.$image);
    }

any idea?

Handling character limits and URL wrapping

I briefly looked through the code for this but didn't immediately see anything that calculated the tweet length before sending it to the server. I discovered in some of my own work with the API that it does odd things when performing URL wrapping with the t.co links. This can change the character count from what it might seem.

This may not even be an issue as you might be okay with the failure handling catching that but I wanted to make you aware of it. Here's more information about Twitter character counts: Twitter API docs.

Refactoring media twitter status

Hi @christophrumpel , based on what we talk here #13 for providing user experience . what about if we create a method for images like

public function toTwitter($notifiable) {
    return new TwitterStatusUpdate(
        'Laravel notifications are awesome!',
    )->withImage([
        public_path('marcel.png'), public_path('mohamed.png'), public_path('freek.png')
    ]);
}

or as i prefer to create an twitter image class that allow us more functionality like validating images before post it or throw exception for some cases of uploading images

public function toTwitter($notifiable) {
    return new TwitterStatusUpdate(
        'Laravel notifications are awesome!',
    )->withMedia([
        new TwitterImage(public_path('marcel.png')), 
        new TwitterImage(public_path('mohamed.png')), 
        new TwitterImage(public_path('freek.png'))
    ]);
}

You must supply a readable file error when using withImage and AWS S3

The following code where $image is a publicly accessible jpeg image causes an error:

return (new TwitterStatusUpdate($message))->withImage($image);

The error is:
"message": "You must supply a readable file", "exception": "InvalidArgumentException", "file": "D:\\project\\vendor\\abraham\\twitteroauth\\src\\TwitterOAuth.php"

Any thoughts as to why this is happenign?

Set Twitter username in TwitterDirectMessage from User model routeNotificationForTwitter

I have a routeNotificationForTwitter on my User model which returns the Twitter username for my user, how can I access this within my notification's toTwitter method?

/**
 * Route the notification for Twitter.
 *
 * @return string
 */
public function routeNotificationForTwitter($notification)
{
    try {
        $availableIntegration = AvailableIntegration::where('slug', 'twitter')
                                                    ->first();

        $userIntegration = UserIntegration::where('user_id', $this->id)
                                          ->where('available_integration_id', $availableIntegration->id)
                                          ->first();

        if (!$userIntegration) {
            return null;
        }

        return $userIntegration->schema->twitter_username;
    } catch (\Exception $e) { }

    return null;
}
    /**
     * Get the Twitter representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toTwitter($notifiable)
    {
        $data = [
            'type' => 'monitor-down',
            'name' => $this->emailData['monitor_name'],
            'url' => $this->emailData['monitor_url'],
            'value' => 'down'
        ];

        try {
            $this->createHistoryEntry('twitter', 'Monitor Down', $data, $notifiable);
        } catch (\Exception $e) { }

        $monitorName = $this->emailData['monitor_name'];
        $monitorURL = $this->emailData['monitor_url'];

        return new TwitterDirectMessage("factfinder_all", "Your monitor $monitorName -- ($monitorURL) -- has just gone DOWN");
    }

Adding links to tweets

Hi,

How do you add links inside tweet when using TwitterStatusUpdate

The following renders as escaped html on twitter:

  return new TwitterStatusUpdate( '<a href="http://example.com">http://example.com</a>');

Reply to tweet feature request

I want to be able to reply to a tweet with status update. Very useful with Twitter bots that have a Laravel back-end.

I'm willing to code this.

This package now breaks authentication when creating new apps

This package now break when you create a new app in the twitter developer console.

To replicate:

Create a standalone app in the twitter developer console so that we can still use the v1 twitter endpoints.
The generated access key will default to read only permissions, so to enable read write permissions update the user authentication settings for the app to Read and write and Direct message. Set the type of app to web app
Regenerate the keys
Add the keys inside your laravel .env file.

If you then test the package using a laravel application you'll get error

   [2023-04-28 15:25:06] local.ERROR: Couldn't post notification. Response: Invalid or expired token. {"exception":"[object] (NotificationChannels\\Twitter\\Exceptions\\CouldNotSendNotification(code: 0): Couldn't post notification. Response: Invalid or expired token. at C:\\project\\vendor\\laravel-notification-channels\\twitter\\src\\Exceptions\\CouldNotSendNotification.php:17)

Not sure if your package should include sending a bearer token to authneticate

Conflict


 isensum: composer require laravel-notification-channels/twitter
Using version ^3.0 for laravel-notification-channels/twitter
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpspec/phpspec 2.2.1 -> satisfiable by phpspec/phpspec[2.2.1].
    - Conclusion: remove symfony/console v4.4.2
    - Conclusion: don't install symfony/console v4.4.2
    - phpspec/phpspec 2.2.1 requires symfony/process ~2.1 -> satisfiable by symfony/process[2.1.x-dev, 2.2.x-dev, 2.3.x-dev, 2.4.x-dev, 2.5.x-dev, 2.6.x-dev, 2.7.x-dev, 2.8.x-dev, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32, v2.3.33, v2.3.34, v2.3.35, v2.3.36, v2.3.37, v2.3.38, v2.3.39, v2.3.4, v2.3.40, v2.3.41, v2.3.42, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.0-BETA1, v2.4.0-BETA2, v2.4.0-RC1, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.0-BETA1, v2.5.0-BETA2, v2.5.0-RC1, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.0-BETA1, v2.6.0-BETA2, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.0-BETA1, v2.7.0-BETA2, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.40, v2.7.41, v2.7.42, v2.7.43, v2.7.44, v2.7.45, v2.7.46, v2.7.47, v2.7.48, v2.7.49, v2.7.5, v2.7.50, v2.7.51, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.35, v2.8.36, v2.8.37, v2.8.38, v2.8.39, v2.8.4, v2.8.40, v2.8.41, v2.8.42, v2.8.43, v2.8.44, v2.8.45, v2.8.46, v2.8.47, v2.8.48, v2.8.49, v2.8.5, v2.8.50, v2.8.52, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
    - symfony/process 2.1.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.2.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.3.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.4.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.5.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.6.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.7.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process 2.8.x-dev conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.12 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.13 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.1.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.2.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.12 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.13 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.14 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.15 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.16 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.17 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.18 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.19 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.20 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.21 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.22 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.23 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.24 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.25 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.26 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.27 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.28 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.29 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.30 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.31 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.32 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.33 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.34 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.35 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.36 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.37 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.38 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.39 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.40 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.41 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.42 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.3.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.0-BETA1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.0-BETA2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.0-RC1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.4.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.0-BETA1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.0-BETA2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.0-RC1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.12 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.5.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.0-BETA1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.0-BETA2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.12 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.13 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.6.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.0-BETA1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.0-BETA2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.12 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.13 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.14 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.15 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.16 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.17 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.18 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.19 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.20 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.21 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.22 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.23 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.24 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.25 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.26 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.27 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.28 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.29 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.30 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.31 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.32 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.33 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.34 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.35 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.36 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.37 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.38 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.39 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.40 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.41 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.42 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.43 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.44 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.45 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.46 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.47 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.48 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.49 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.50 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.51 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.7.9 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.0 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.0-BETA1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.1 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.10 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.11 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.12 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.13 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.14 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.15 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.16 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.17 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.18 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.19 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.2 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.20 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.21 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.22 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.23 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.24 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.25 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.26 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.27 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.28 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.29 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.3 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.30 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.31 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.32 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.33 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.34 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.35 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.36 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.37 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.38 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.39 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.4 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.40 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.41 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.42 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.43 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.44 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.45 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.46 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.47 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.48 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.49 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.5 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.50 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.52 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.6 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.7 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.8 conflicts with symfony/console[v4.4.2].
    - symfony/process v2.8.9 conflicts with symfony/console[v4.4.2].
    - Installation request for symfony/console (locked at v4.4.2) -> satisfiable by symfony/console[v4.4.2].


Installation failed, reverting ./composer.json to its original content.

Undefined property: stdClass::$errors

I'm trying to create a status. But when I hit the URL, I get the error "Undefined property: stdClass::$errors"

My code below.

 public function via($notifiable): array
    {
        return [TwitterChannel::class];
    }

    public function toTwitter($notifiable)
    {

        return new TwitterStatusUpdate('Laravel notifications are awesome!');
    }

route

Route::get('/test', function () {
    Notification::route(\NotificationChannels\Twitter\TwitterChannel::class,'')
        ->notify(new TwitterNotification());
});

In composer.json

  "require": {
        "php": "^7.2.5",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.9.2",
        "laravel-notification-channels/twitter": "^4.1.0",
        "laravel/tinker": "^2.0"
    },

Call to undefined method App\Jobs\PostToTwitter::via()

hi
i created a notification:

<?php

namespace App\Notifications;

use App\Post;
use NotificationChannels\Twitter\TwitterChannel;
use NotificationChannels\Twitter\TwitterStatusUpdate;
use Illuminate\Notifications\Notification;

class PostToTwitterNotification extends Notification
{

    private $post;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Post $post)
    {
        $this->post = $post;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [TwitterChannel::class];
    }

    /**
     * @param $notifiable
     * @return TwitterStatusUpdate
     * @throws \NotificationChannels\Twitter\Exceptions\CouldNotSendNotification
     */
    public function toTwitter($notifiable)
    {
        return new TwitterStatusUpdate("{$this->post->title} \n {$this->post->url}");
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('The introduction to the notification.')
            ->action('Notification Action', url('/'))
            ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            $this->post
        ];
    }
}

but i get the error: Call to undefined method App\Jobs\PostToTwitter::via()

what can i do?

Per User Settings

The system I'm building is tenated, so I need to be able to pull OAuth from each of the different models, instead of a site wide config. The site is tweeting as a team that is in the site, not the site itself. It looks like Laravel provides routing functions for the notifications, but this class isn't setup to use it. I can do some work and a PR to add it, but wanted to get your thoughts first.

First question is do you want this package to handle this use case?

If yes - the way I'm seeing it there's really two options: --we can either do specific with a fallback to the generic if the route function isn't specified--, or we have a way to switch between one or the other (either config or registering different providers or something). Do you have a preference? I think I prefer specific switch since there doesn't seem to be many use cases for the fallback, although fallback would probably be easier to code and maintain.

Any thoughts?


After thinking about it more, the fallback is not a good idea since it would be counter to how most, if not all, notifications work - that's just asking for trouble.

PHP 8 support

Hello,

When running composer update on a PHP 8 machine, I get the following:

    - Root composer.json requires laravel-notification-channels/twitter ^5.0.1 -> satisfiable by laravel-notification-channels/twitter[v5.0.1].
    - laravel-notification-channels/twitter v5.0.1 requires php ^7.3 -> your php version (8.0.0) does not satisfy that requirement.

Driver [Twitter] not supported

I came across this issue, which is identical to mine, except let's fast forward to present day, I'm working inside a Laravel 8 application and am using PHP 7.4, I'm using version 5.1.0 of this package and have just set it up, my notification class (the important bits) looks like this...

<?php

namespace App\Notifications\Monitor;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Messages\NexmoMessage;

use NotificationChannels\Discord\DiscordChannel;
use NotificationChannels\Discord\DiscordMessage;
use NotificationChannels\Twitter\TwitterChannel;
use NotificationChannels\Twitter\TwitterDirectMessage;

use App\Models\NotificationHistory;
use App\Traits\Plans;

class MonitorDown extends Notification implements ShouldQueue
{
    use Queueable, Plans;

    public $monitor;
    public $emailData;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($monitor, $emailData)
    {
        $this->monitor = $monitor;
        $this->emailData = $emailData;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        $preferences = json_decode($notifiable->notification_preferences);

        if (!$notifiable->is_subscribed) {
            $preferences->monitors->down = array_merge(array_diff($preferences->monitors->down, [
                'nexmo', 'discord', 'twitter'
            ]));
        }

        // not working
        return ['twitter', 'discord'];

        // not working
        return [TwitterChannel::class, 'discord'];

        // not working
        return [TwitterChannel::class];
        
        // return $preferences->monitors->down;
    }

    /**
     * Determine which queues should be used for each notification channel.
     *
     * @return array
     */
    public function viaQueues()
    {
        return [
            'mail' => 'notifications',
            'database' => 'notifications',
            'slack' => 'notifications',
            'nexmo' => 'notifications',
            'discord' => 'notifications',
            'twitter' => 'notifications'
        ];
    }

    /**
     * Get the Twitter representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toTwitter($notifiable)
    {
        $data = [
            'type' => 'monitor-down',
            'name' => $this->emailData['monitor_name'],
            'url' => $this->emailData['monitor_url'],
            'value' => 'down'
        ];

        try {
            $this->createHistoryEntry('twitter', 'Monitor Down', $data, $notifiable);
        } catch (\Exception $e) { }

        $monitorName = $this->emailData['monitor_name'];
        $monitorURL = $this->emailData['monitor_url'];

        return new TwitterDirectMessage("factfinder_all", "Your monitor $monitorName -- ($monitorURL) -- has just gone DOWN");
    }

    /**
     * Create a history entry
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function createHistoryEntry($method = 'database', $type = '', $data, $notifiable)
    {
        try {
            $history = new NotificationHistory();
            $history->method = $method;
            $history->type = $type;
            $history->data = json_encode($data);
            $history->notification_id = isset($this->id) ? $this->id : '';
            $history->user_id = $notifiable['id'];
            $history->save();
        } catch (\Exception $e) { }
    }
}

You'll see that I've tried several ways to get the notifications to work:

// not working
return ['twitter', 'discord'];

// not working
return [TwitterChannel::class, 'discord'];

// not working
return [TwitterChannel::class];

But still, the error returned is:

InvalidArgumentException: Driver [twitter] not supported.

no usage information

Usage information says now to install but not how to use

what code should i post in Model, what in Controller? nothing

Driver [App\Notifications\TwitterChannel] not supported.

Hello, so i'm new and would like some inside from you guys.

This is my notification class

class NewPostPublished extends Notification
{
    use Queueable;

    public function via($notifiable)
    {
        return [TwitterChannel::class];
    }

    public function toTwitter($notifiable) {
        return new TwitterStatusUpdate('Laravel notifications are awesome!');
    }

}

This one, is controller

class TwitterController extends Controller
{
    public function updateStatus(Request $request){
      User::find(1)->first()->notify(new NewPostPublished($lala));
    }
}

Config\App.php already inserted and .env file also had been setup

Any idea what might wrong?

Error Output

InvalidArgumentException in Manager.php line 90:
Driver [App\Notifications\TwitterChannel] not supported.
in Manager.php line 90
at Manager->createDriver('App\Notifications\TwitterChannel') in ChannelManager.php line 230
at ChannelManager->createDriver('App\Notifications\TwitterChannel') in Manager.php line 63
at Manager->driver('App\Notifications\TwitterChannel') in ChannelManager.php line 79
at ChannelManager->sendNow(object(Collection), object(NewPostPublished)) in ChannelManager.php line 43
at ChannelManager->send(object(Collection), object(NewPostPublished)) in RoutesNotifications.php line 18
at User->notify(object(NewPostPublished)) in TwitterController.php line 13
at TwitterController->updateStatus(object(Request))
at call_user_func_array(array(object(TwitterController), 'updateStatus'), array(object(Request))) in Controller.php line 55
at Controller->callAction('updateStatus', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(TwitterController), 'updateStatus') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ThrottleRequests.php line 49
at ThrottleRequests->handle(object(Request), object(Closure), '60', '1') in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
at require('/Applications/workdirectory/playground/public/index.php') in server.php line 106

Update: insert error message

Twitter v2 now breaks this package by default

I've just set up Twitter notifications that I need in my project, after trying it out, and getting an error in the TwitterDirectMessage.php file it's clear that when adding a custom log into this file that the current version of the package is unsupported with Twitter v2:

As per this earlier in the year, this has now indeed come into affect, and in addition, I cannot upgrade my application past version 5 as version 6 requires PHP 8.

Any chance you could get some support in for both versions? my error I'm getting:

{"user":"{"errors":[{"message":"You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you\u2019ll need to apply for Elevated access via the Developer Portal. You can learn more here: https:\/\/developer.twitter.com\/en\/docs\/twitter-api\/getting-started\/about-twitter-api#v2-access-leve","code":453}]}"}

laravel 5.8 support

Hey, guys, can u update this package to be compatible to 5.8 and also update it in Packagist as well?

Thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.