aboutsummaryrefslogtreecommitdiff
path: root/api/free_sms.go
blob: f09a1d1220bace27a6a49fe89b46a6ff2511acc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package api

import (
	"fmt"
	"net/http"
	"net/url"
)

func SendSMS(user, pass, msg string) error {
	form := url.Values{
		"user": []string{user},
		"pass": []string{pass},
		"msg":  []string{msg},
	}

	response, err := http.Get(fmt.Sprintf("https://smsapi.free-mobile.fr/sendmsg?%s", form.Encode()))
	if err != nil {
		return err
	}

	if response.StatusCode != 200 {
		return fmt.Errorf("Cannot send sms: status code %v", response.StatusCode)
	}

	return nil
}