File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,9 +14,6 @@ if (-not (QWINSTA | FINDSTR $env:USERNAME)) {
1414$MY_NUMBER = ' +xxx'
1515$HER_NUMBER = ' +xxx'
1616
17- $TWILIO_ACCOUNT_SID = ' xxx'
18- $TWILIO_AUTH_TOKEN = ' xxx'
19-
2017$REASONS =
2118 ' Working hard' ,
2219 ' Gotta ship this feature' ,
@@ -26,14 +23,18 @@ $RAND = Get-Random -Maximum $REASONS.Count
2623
2724$MSG = " Late at work. $REASONS [$RAND ]"
2825
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+ }
2933
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
3335try {
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
3537}
3638catch {
3739 Write-Host " Failed to send SMS: $_ "
3840}
39-
You can’t perform that action at this time.
0 commit comments