aboutsummaryrefslogtreecommitdiff
path: root/api/free_sms.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/free_sms.go')
-rw-r--r--api/free_sms.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/api/free_sms.go b/api/free_sms.go
new file mode 100644
index 0000000..f09a1d1
--- /dev/null
+++ b/api/free_sms.go
@@ -0,0 +1,26 @@
1package api
2
3import (
4 "fmt"
5 "net/http"
6 "net/url"
7)
8
9func SendSMS(user, pass, msg string) error {
10 form := url.Values{
11 "user": []string{user},
12 "pass": []string{pass},
13 "msg": []string{msg},
14 }
15
16 response, err := http.Get(fmt.Sprintf("https://smsapi.free-mobile.fr/sendmsg?%s", form.Encode()))
17 if err != nil {
18 return err
19 }
20
21 if response.StatusCode != 200 {
22 return fmt.Errorf("Cannot send sms: status code %v", response.StatusCode)
23 }
24
25 return nil
26}