@@ -14,9 +14,11 @@ This package makes it easy to send notifications using [Twitter](https://dev.twi
1414## Contents
1515
1616- [ Installation] ( #installation )
17- - [Setting up the Twitter service](#setting-up-the-Twitter -service)
17+ - [ Setting up the Twitter service] ( #setting-up-the-twitter -service )
1818- [ Usage] ( #usage )
19- - [Available Message methods](#available-message-methods)
19+ - [Publish Twitter status update](#publish-twitter-status-update)
20+ - [Publish Twitter status update with images](#publish-twitter-status-update-with-images)
21+ - [ Send a direct message] ( #send-a-direct-message )
2022- [ Changelog] ( #changelog )
2123- [ Testing] ( #testing )
2224- [ Security] ( #security )
@@ -73,7 +75,7 @@ Follow Laravel's documentation to add the channel to your Notification class.
7375use NotificationChannels\Twitter\TwitterChannel;
7476use NotificationChannels\Twitter\TwitterMessage;
7577
76- class NewForumDiscussionCreated extends Notification
78+ class NewsWasPublished extends Notification
7779{
7880
7981 /**
@@ -88,25 +90,37 @@ class NewForumDiscussionCreated extends Notification
8890 }
8991
9092 public function toTwitter($notifiable) {
91- return new TwitterMessage('Why Laravel Notification Channels are awesome -> url:... ');
93+ return new TwitterStatusUpdate(' Laravel notifications are awesome! ');
9294 }
9395}
9496```
9597
96- Take a closer look at the ` TwitterMessage ` object. Like this, it will send a status update to your Twitter timeline .
98+ Take a closer look at the ` TwitterStatusUpdate ` object. This is where the magic happens .
9799```` php
98100public function toTwitter($notifiable) {
99- return new TwitterMessage('Why Laravel Notification Channels are awesome -> url:... ');
101+ return new TwitterStatusUpdate(' Laravel notifications are awesome! ');
100102}
101- ````
103+ ````
104+ ### Publish Twitter status update with images
105+ It is possible to publish images with your status update too. You just have to pass the image paths as the second
106+ parameter. These images will then be shown next to your Twitter status message.
107+ ```` php
108+ public function toTwitter($notifiable) {
109+ return new TwitterStatusUpdate(
110+ 'Laravel notifications are awesome!',
111+ [public_path('marcel.png'), public_path('mohamed.png'), public_path('freek.png')]
112+ );
113+ }
114+ ````
102115### Send a direct message
103- But it is possible to send a Twitter direct message too. Just provide a second argument. The first one will be the user, the second one the message:
116+ To send a Twitter direct message to a specific user, you will need the ` TwitterDirectMessage ` class. Provide the Twitter
117+ user handler as the first parameter and the the message as the second one.
104118```` php
105119public function toTwitter($notifiable) {
106- return new TwitterMessage('christophrumpel ', 'Hey Christoph, whats up? ');
120+ return new TwitterDirectMessage('marcelpociot ', 'Hey Marcel, it was nice meeting you at the Larcon. ');
107121}
108122````
109- Make sure the user is following you on Twitter. If this is not the case, it will throw an Exception .
123+ Make sure the user is following you on Twitter to make this work .
110124
111125
112126
0 commit comments