File tree Expand file tree Collapse file tree 7 files changed +186
-13
lines changed Expand file tree Collapse file tree 7 files changed +186
-13
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Http \Controllers ;
4
+
5
+ use Illuminate \Http \Request ;
6
+
7
+ use App \Http \Requests ;
8
+ use App \Http \Controllers \Controller ;
9
+ use MJErwin \Clockwork \ClockworkClient ;
10
+ use MJErwin \Clockwork \Message ;
11
+
12
+ class ClockworkController extends Controller
13
+ {
14
+
15
+ protected $ apiKey ;
16
+ protected $ client ;
17
+
18
+ public function __construct ()
19
+ {
20
+ $ this ->apiKey = env ('CLOCKWORK_API_KEY ' );
21
+ $ this ->client = new ClockworkClient ($ this ->apiKey );
22
+ $ this ->message = new Message ();
23
+ $ this ->message ->setNumber ('07700900123 ' );
24
+ $ this ->message ->setContent ('Check out this message! ' );
25
+
26
+ }
27
+ /**
28
+ * Return all data to the Clockwork API dashboard
29
+ * @return mixed
30
+ */
31
+ public function getPage ()
32
+ {
33
+ return view ('api.clockwork ' );
34
+ }
35
+
36
+ /**
37
+ * Send a Text Message
38
+ * @param Request $request
39
+ * @return string
40
+ */
41
+ public function sendTextMessage (Request $ request )
42
+ {
43
+ $ this ->validate ($ request , [
44
+ 'telephone ' => 'required '
45
+ ]);
46
+
47
+ $ number = $ request ->input ('number ' );
48
+ $ message = 'Testing Clockwork SMS #LaravelHackathonStarter ' ;
49
+
50
+ $ response = $ this ->client ->sendMessage ($ this ->message );
51
+ dd ($ response );
52
+
53
+ //return redirect()->back()->with('info','Your Message has been sent successfully');
54
+ }
55
+ }
Original file line number Diff line number Diff line change 98
98
'middleware ' => ['auth ' ]
99
99
]);
100
100
101
+ Route::get ('/api/clockwork ' , [
102
+ 'uses ' => 'ClockworkController@getPage ' ,
103
+ 'as ' => 'api.clockwork ' ,
104
+ 'middleware ' => ['auth ' ]
105
+ ]);
106
+
107
+ Route::post ('/api/clockwork ' , [
108
+ 'uses ' => 'ClockworkController@sendTextMessage ' ,
109
+ 'middleware ' => ['auth ' ]
110
+ ]);
111
+
101
112
Route::post ('/tweet/new ' , [
102
113
'uses ' => 'TwitterController@sendTweet ' ,
103
114
'as ' => 'tweet.new ' ,
Original file line number Diff line number Diff line change 15
15
"thujohn/twitter" : " ^2.1" ,
16
16
"metalmatze/lastfm-api-wrapper" : " dev-master" ,
17
17
"aloha/twilio" : " ^2.0" ,
18
- "fabpot/goutte" : " ^3.1"
18
+ "fabpot/goutte" : " ^3.1" ,
19
+ "mjerwin/clockwork-sms" : " ^0.9.1"
19
20
},
20
21
"require-dev" : {
21
22
"fzaninotto/faker" : " ~1.4" ,
Original file line number Diff line number Diff line change
1
+ @extends (' layouts.master' )
2
+
3
+ @section (' content' )
4
+ <div class =" main-container" >
5
+ @include (' layouts.partials.alerts' )
6
+
7
+ <div class =" page-header" >
8
+ <h2 ><i class =" fa fa-phone" ></i > Clockwork SMS API</h2 >
9
+ </div >
10
+
11
+ <div class =" btn-group btn-group-justified" >
12
+ <a href =" http://github.com/mediaburst/node-clockwork" target =" _blank" class =" btn btn-primary" >
13
+ <i class =" fa fa-check-square-o" ></i > Clockwork Node
14
+ </a >
15
+ <a href =" http://www.clockworksms.com/doc/clever-stuff/xml-interface/send-sms/" target =" _blank" class =" btn btn-primary" >
16
+ <i class =" fa fa-code-fork" ></i > XML API
17
+ </a >
18
+ </div >
19
+
20
+ <h4 >Send a text message</h4 >
21
+
22
+ <div class =" row" >
23
+ <div class =" col-sm-6" >
24
+ <form role =" form" method =" POST" action =" {{ route (' api.clockwork' ) } }" >
25
+ {!! csrf_field () ! !}
26
+ <div class =" form-group{{ $errors -> has (' telephone' ) ? ' has-error' : ' ' } }" >
27
+ <div class =" input-group" >
28
+ <input type =" text" name =" telephone" placeholder =" Phone Number (international format)" class =" form-control" >
29
+ <span class =" input-group-btn" >
30
+ <button type =" submit" class =" btn btn-success" >Send</button >
31
+ </span >
32
+ </div >
33
+ @if ($errors -> has (' telephone' ) )
34
+ <span class =" help-block" >{{ $errors -> first (' telephone' ) } } </span >
35
+ @endif
36
+ </div >
37
+ </form >
38
+ </div >
39
+ </div >
40
+
41
+ <br >
42
+ </div >
43
+ @stop
Original file line number Diff line number Diff line change 29
29
<div class =" form-group{{ $errors -> has (' number' ) ? ' has-error' : ' ' } }" >
30
30
<label class =" control-label" >Number to text</label >
31
31
<input type =" text" name =" number" autofocus =" " class =" form-control" >
32
- @if ($errors -> has (' number' ) )
32
+ @if ($errors -> has (' number' ) )
33
33
<span class =" help-block" >{{ $errors -> first (' number' ) } } </span >
34
34
@endif
35
35
</div >
Original file line number Diff line number Diff line change 133
133
</div >
134
134
</a >
135
135
</div >
136
- <div class =" col-sm-4" >
137
- <a href =" /api/venmo" style =" color : #fff " >
138
- <div style =" background-color : #1f93cf " class =" panel panel-default" >
139
- <div class =" panel-body" >
140
- <img src =" http://i.imgur.com/90tl9C8.gif" height =" 40" > Venmo
141
- </div >
142
- </div >
143
- </a >
144
- </div >
145
136
<div class =" col-sm-4" >
146
137
<a href =" /api/yahoo" style =" color : #fff " >
147
138
<div style =" background-color : #3d048b " class =" panel panel-default" >
You can’t perform that action at this time.
0 commit comments