aboutsummaryrefslogblamecommitdiff
path: root/api/free_sms.go
blob: f09a1d1220bace27a6a49fe89b46a6ff2511acc2 (plain) (tree)

























                                                                                                         
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
}