File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,6 @@ if (-not (QWINSTA | FINDSTR $env:USERNAME)) {
14
14
$MY_NUMBER = ' +xxx'
15
15
$HER_NUMBER = ' +xxx'
16
16
17
- $TWILIO_ACCOUNT_SID = ' xxx'
18
- $TWILIO_AUTH_TOKEN = ' xxx'
19
-
20
17
$REASONS =
21
18
' Working hard' ,
22
19
' Gotta ship this feature' ,
@@ -26,14 +23,18 @@ $RAND = Get-Random -Maximum $REASONS.Count
26
23
27
24
$MSG = " Late at work. $REASONS [$RAND ]"
28
25
26
+ $API_URL = " https://api.twilio.com/2010-04-01/Accounts/$env: TWILIO_ACCOUNT_SID /Messages"
27
+ $BASE64AUTHINFO = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes((" {0}:{1}" -f $env: TWILIO_ACCOUNT_SID , $env: TWILIO_AUTH_TOKEN )))
28
+ $body = @ {
29
+ From = $MY_NUMBER ;
30
+ To = $HER_NUMBER ;
31
+ Body = $MSG ;
32
+ }
29
33
30
- $BASE64AUTHINFO = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes((" {0}:{1}" -f $TWILIO_ACCOUNT_SID , $TWILIO_AUTH_TOKEN )))
31
-
32
- # Send a text messag and Log errors
34
+ # Send a text message and Log errors
33
35
try {
34
- Invoke-RestMethod - Method Post - Headers @ {Authorization = (" Basic {0}" -f $BASE64AUTHINFO )} " https://api.twilio.com/2010-04-01/Accounts/ $TWILIO_ACCOUNT_SID /Messages " - Body " From= $MY_NUMBER &To= $HER_NUMBER &Body= $MSG " > $null
36
+ Invoke-RestMethod - Method Post - Headers @ {Authorization = (" Basic {0}" -f $BASE64AUTHINFO )} $API_URL - Body $body > $null
35
37
}
36
38
catch {
37
39
Write-Host " Failed to send SMS: $_ "
38
40
}
39
-
You can’t perform that action at this time.
0 commit comments