Esempio n. 1
0
func main() {
	act := twiliogo.NewAccountFromEnv()
	messageList, err := act.Sms.List(sms.Filter{})
	if err != nil {
		fmt.Println("Error retrieving sms: ", err.Error())
		return
	}
	fmt.Printf("%#v\n", messageList)
	for _, m := range *messageList.Messages {
		fmt.Println(m.Sid)
	}

	for {
		// keep trying to get the next page of results
		err = messageList.Next()
		if err != nil {
			fmt.Println("Error retrieving sms: ", err.Error())
			return
		}
		fmt.Printf("%#v\n", messageList)
		for _, m := range *messageList.Messages {
			fmt.Println(m.Sid)
		}
	}
}
Esempio n. 2
0
func main() {
	act := twiliogo.NewAccountFromEnv()

	notificationList, err := act.Notifications.List(notifications.Filter{})
	if err != nil {
		fmt.Println("Errored while getting notifications")
		fmt.Println(err.Error())
		return
	}
	for _, n := range *notificationList.Notifications {
		fmt.Printf("%#v\n", n)
	}

	fmt.Println("Enter a sid to delete a notifcation")
	sid, _ := bufio.NewReader(os.Stdin).ReadString('\n')
	if len(sid) != 35 {
		fmt.Println("Exiting")
		return
	}
	fmt.Printf("Sending a DELETE for {%s}\n", sid[0:34])

	err = act.Notifications.Delete(sid[0:34])
	if err != nil {
		fmt.Println("Error deleting notification: ", err.Error())
		return
	}
	fmt.Printf("{%s} deleted\n", sid[0:34])
}
Esempio n. 3
0
func main() {

	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Transcriptions.List()
	if err != nil {
		fmt.Println("Error getting recording: ", err.Error())
	}
	fmt.Printf("%#v\n", resp)
	for _, t := range *resp.Transcriptions {
		fmt.Printf("%#v\n", t)
	}
}
Esempio n. 4
0
func main() {
	fmt.Println("Waiting for sid to send request")
	sid, _ := bufio.NewReader(os.Stdin).ReadString('\n')
	fmt.Printf("Sending a GET for {%s}\n", sid[0:34])

	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Transcriptions.Get(sid[0:34])
	if err != nil {
		fmt.Println("Error getting recording: ", err.Error())
	}
	fmt.Printf("%#v\n", resp)
}
Esempio n. 5
0
func main() {
	fmt.Println("Waiting for sid to send request")
	sid, _ := bufio.NewReader(os.Stdin).ReadString('\n') // wait to let server catching callback start
	fmt.Printf("Sending a GET for {%s}\n", sid[0:34])

	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Sms.Get(sid[0:34])
	if err != nil {
		fmt.Println("Error sending sms: ", err.Error())
	}
	fmt.Printf("Sent %s to %s\n", resp.Body, resp.To)
}
Esempio n. 6
0
func main() {
	fmt.Println("Waiting for sid to delete")
	sid, _ := bufio.NewReader(os.Stdin).ReadString('\n')
	fmt.Printf("Sending a DELETE for {%s}\n", sid[0:34])

	act := twiliogo.NewAccountFromEnv()
	err := act.Transcriptions.Delete(sid[0:34])
	if err != nil {
		fmt.Println("Error getting recording: ", err.Error())
	} else {
		fmt.Println("Transcription ", sid[0:34], " successfully deleted!")
	}
}
Esempio n. 7
0
func main() {
	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Recordings.List(recording.ListFilter{
		CallSid: "CAa612188279206d89f1d75e3690536011",
	})
	if err != nil {
		fmt.Println("Error getting call list: ", err.Error())
	}

	fmt.Printf("%#v\n", resp)
	for _, m := range *resp.Recordings {
		fmt.Printf("%#v\n", m)
	}
}
Esempio n. 8
0
func main() {
	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Voice.List(voice.ListFilter{
		From: "+16162882901",
	})
	if err != nil {
		fmt.Println("Error getting call list: ", err.Error())
	}

	fmt.Printf("%#v\n", resp)
	for _, m := range *resp.Calls {
		fmt.Printf("%#v\n", m)
	}
}
Esempio n. 9
0
func updateCall(sid string) {
	act := twiliogo.NewAccountFromEnv()
	fmt.Println("Send an update?")
	bufio.NewReader(os.Stdin).ReadString('\n')
	fmt.Println("Posting update for ", sid)

	resp, err := act.Voice.Update(voice.Update{
		URL:    "http://twimlbin.com/701ed8a7",
		Method: "POST",
	}, sid)

	if err != nil {
		fmt.Println("Error making call: ", err.Error())
	}
	fmt.Printf("%#v\n", resp)
}
Esempio n. 10
0
func makeCall() {
	fmt.Println("Waiting...")
	bufio.NewReader(os.Stdin).ReadString('\n')
	fmt.Println("Here we gooo")
	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Voice.Call(voice.Call{
		From: "+ {Your ###} ",
		To:   "+ {Their ###<3 }",
		URL:  "http://twimlbin.com/558a498f",
	})

	if err != nil {
		fmt.Println("Error making call: ", err.Error())
	}
	fmt.Printf("%#v\n", resp)
}
Esempio n. 11
0
func sendSms() {
	fmt.Println("Waiting for ENTER to send")
	bufio.NewReader(os.Stdin).ReadString('\n') // wait to let server catching callback start
	fmt.Println("Sending")
	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Sms.Send(sms.Post{
		From:           "+{ Your Twilio Number }",
		To:             "+{ Your Destination Number }",
		Body:           "Yo",
		StatusCallback: "{ Your callback endpoint }",
	})
	if err != nil {
		fmt.Println("Error sending sms: ", err.Error())
	}
	fmt.Printf("%#v\n", resp)
}
Esempio n. 12
0
func makeCall() string {
	fmt.Println("Waiting...")
	bufio.NewReader(os.Stdin).ReadString('\n')
	fmt.Println("Here we gooo")
	act := twiliogo.NewAccountFromEnv()
	resp, err := act.Voice.Call(voice.Call{
		From: "+16162882901",
		To:   "+16164601267",
		URL:  "http://twimlbin.com/558a498f",
	})

	if err != nil {
		fmt.Println("Error making call: ", err.Error())
	}
	fmt.Printf("%#v\n", resp)
	return resp.Sid
}
Esempio n. 13
0
func main() {
	act := twiliogo.NewAccountFromEnv()

	afterDate := time.Now().AddDate(0, 0, -7)
	notificationList, err := act.Notifications.List(notifications.Filter{
		AfterMessageDate: &afterDate,
	})
	if err != nil {
		fmt.Println("Errored while getting notifications")
		fmt.Println(err.Error())
		return
	}
	fmt.Printf("All %d notifications from after %s:\n", len(*notificationList.Notifications), afterDate.Format(common.GMTTimeLayout))
	for _, n := range *notificationList.Notifications {
		fmt.Printf("%#v\n", n)
	}
}
Esempio n. 14
0
func main() {
	act := twiliogo.NewAccountFromEnv()

	appList, err := act.Applications.List(applications.ListFilter{})
	if err != nil {
		fmt.Println("Error sending sms: ", err.Error())
	}

	fmt.Println("Current applications:")
	for _, app := range *appList.Applications {
		fmt.Printf("%#v\n", app)
	}

	fmt.Println("Waiting for sid to send request")
	name, _ := bufio.NewReader(os.Stdin).ReadString('\n') // wait to let server catching callback start
	name = strings.TrimRight(name, "\n")
	fmt.Printf("Creating a new app called %s\n", name)

	newApp, err := act.Applications.Create(applications.Application{FriendlyName: name})
	if err != nil {
		fmt.Println("Error creating app: ", err.Error())
	}
	fmt.Printf("%#v\n", newApp)
}
Esempio n. 15
0
func main() {
	act := twiliogo.NewAccountFromEnv()
	makeCall("+16164601267", act)
	sid2 := makeCall("+16628551523", act)
	fmt.Println("Mute participant?")
	bufio.NewReader(os.Stdin).ReadString('\n')
	resp, err := act.Conferences.List(conference.ListFilter{
		Status:      "in-progress",
		DateCreated: &(common.JSONTime{Time: time.Now()}), //Set to today's date
	})
	if err != nil {
		fmt.Println("Error getting conferences: ", err.Error())
	}

	confSid := ""

	for _, c := range *resp.Conferences {
		confSid = c.Sid
	}

	partResp, err := act.Conferences.GetParticipant(confSid, sid2)

	if err != nil {
		fmt.Println("Error getting participant: ", err.Error())
	} else {
		fmt.Printf("%#v\n", partResp)

	}

	muteParticipant(confSid, sid2, act)

	fmt.Println("Kick participant?")
	bufio.NewReader(os.Stdin).ReadString('\n')
	kickParticipant(confSid, sid2, act)

}
Esempio n. 16
0
func main() {
	act := twiliogo.NewAccountFromEnv()

	fmt.Println("Sending MMS")
	msg, err := act.Sms.Send(sms.Post{
		From:     "+1{ Your Twilio MMS enabled number }",
		To:       "+1{ Destinatino number }",
		Body:     "Yo",
		MediaURL: "http://i.imgur.com/XcMxly3.jpg", // Cute otter
	})
	if err != nil {
		fmt.Println("Error sending mms: ", err.Error())
		return
	}
	fmt.Printf("%#v\n", msg)

	fmt.Println("Getting MMS media list")
	mediaList, err := act.Sms.GetMediaList(msg.Sid)
	if err != nil {
		fmt.Println("Error getting mms: ", err.Error())
		return
	}
	fmt.Printf("%#v\n", *mediaList.MediaList)
}