#!/bin/bash

SID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
SMSFROM="18005551212"

# make no changes below here #

if [[ -z $1 ]]; then
 echo "ERROR: Missing 11-digit number of recipient"
 echo Syntax: sms-skyetel recipient-11-digit number "Message to send"
 exit
fi
if [[ -z $2 ]]; then
 echo "ERROR: Missing SMS message enclosed in quotes"
 echo Syntax: sms-skyetel recipient-11-digit number "Message to send"
 exit
fi

SMSTO=$1
SMSMSG=$2

curl -X POST -v \
  -H "Content-type: application/json" \
  --user $SID:$SECRET \
  --data @<(cat <<EOF
  {
   "to": "$SMSTO",
   "text": "$SMSMSG"
  }
EOF
) \
  https://sms.skyetel.com/v1/out?from=$SMSFROM

echo " "
echo "Message has been sent to $SMSTO."
