func main() { sms := gosms.NewBulkSMSSMSSender("USERNAME", "PASSWORD") sms.Testmode = 0 sms.RoutingGroup = 2 sms.SenderId = "Tabletten" msg := "https://github.com/jsz/gosms is awesome! -- sent from my Go" receivers := []string{"49178xxxxxx", "49172xxxxxxxx"} //quote gives you the cost of the sms in credits err, quote := sms.GetQuote(receivers, msg) if err != nil { fmt.Println(err) return } price := quote * 3.75 * 0.01 //mad math skills calculate price in MONEYS //we're cheap! if quote > 2.0 { fmt.Printf("sorry, but %.2f credits (%.2f EUR) is too much for a sms!\n", quote, price) return } fmt.Printf("this sms will cost %.4f eur\n", price) if err := sms.Send(receivers, msg); err != nil { fmt.Println(err) return } fmt.Println("sms sent") }
func sendSMS(number, message string) { log.Printf("\t\tsending '%s' to '%s' ...\n", message, number) s := gosms.NewBulkSMSSMSSender("joorek", "warbird") //s.Testmode = 1 //don't send the sms, just perform an API supported test s.RoutingGroup = 2 //let's use the cheap eco route receivers := []string{number} //put a proper tel# here in //let's see how much this sms would cost us _, quote := s.GetQuote(receivers, message) price := quote * 3.75 * 0.01 //quote is in credits. 1 credit = 3.75 eur cent log.Printf("\t\t\tPrice for SMS(%s): %.4f EUR\n", number, price) //send the sms if err := s.Send(receivers, message); err != nil { log.Printf("\t\tcouldn't send sms to '%s': %s\n", number, err) return } fmt.Printf("\t\tsms sent to '%s'!\n", number) }
func main() { s := gosms.NewBulkSMSSMSSender("joorek", "warbird") s.Testmode = 0 //don't send the sms, just perform an API supported test s.RoutingGroup = 2 //let's use the cheap eco route s.SenderId = "Tabletten" msg := "tabletten nehmen!" receivers := []string{"491722579081"} //put a proper tel# here in //let's see how much this sms would cost us _, quote := s.GetQuote(receivers, msg) price := quote * 3.75 * 0.01 //quote is in credits. 1 credit = 3.75 eur cent fmt.Printf("the sms will cost us %.4f EUR\n", price) //send the sms if err := s.Send(receivers, msg); err != nil { fmt.Println(err) return } fmt.Println("sms sent!") }