-
Notifications
You must be signed in to change notification settings - Fork 0
/
sms.go
49 lines (38 loc) · 1.01 KB
/
sms.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"log"
"net/http"
"unicode/utf8"
)
//https://www.omnivoice.eu/api/send_sms.cfm?uname=&pword=&sacc=&message=&destid=&action=test
func sendSMS(url, message, user, pass, cid, sender, sendtype, recepient string) bool {
sendtype = "test"
response, err := http.Get(url + "api/send_sms.cfm?uname=" + user + "&pword=" + pass + "&sacc=" + user + "&cid=" + cid + "&message=" + message + "&destid=" + recepient + "&action=" + sendtype)
if err != nil {
log.Println("Error while downloading", url, ":", err)
}
if response.StatusCode != http.StatusOK {
log.Printf("Server return non-200 status: %v\n", response.Status)
}
defer response.Body.Close()
return true
}
func checkNumbers(numbers []string) bool {
for num := range numbers {
if numbers[num][:2] == "30" {
println("ok")
}
}
return true
}
func checkMessage(message string) bool {
var mlen = false
var menc = false
if len(message) <= 159 {
mlen = true
}
if utf8.Valid([]byte(message)) {
menc = true
}
return mlen && menc
}