Example #1
0
func (this *YunpianAPI) TplGetALL() ([]Template, error) {
	req := httplib.Post(geturl(URL_TPL_GET))
	req.Param("apikey", this.APIKey)
	tpl := Tpls{}
	req.ToJson(&tpl)
	if tpl.Code == 0 {
		return tpl.Templates, nil
	}
	return nil, errors.New(tpl.Detail)
}
Example #2
0
//1.1 查账户信息
func (this *YunpianAPI) UserGet() (User, error) {
	req := httplib.Post(geturl(URL_USER_GET))
	req.Param("apikey", this.APIKey)
	user := User{}
	req.ToJson(&user)
	if user.Code == 0 {
		return user, nil
	}
	return user, errors.New(user.Detail)
}
Example #3
0
//3.7 查看屏蔽词
func (this *YunpianAPI) SmsGetBlackWord(text string) (string, error) {
	req := httplib.Post(geturl(URL_SMS_GETBLACKWORD))
	req.Param("apikey", this.APIKey)
	req.Param("text", text)
	smsgetblackword := SMSGetBlackWord{}
	req.ToJson(&smsgetblackword)
	if smsgetblackword.Code == 0 {
		return smsgetblackword.Result.Black_Word, nil
	}
	return "", errors.New(smsgetblackword.Detail)
}
Example #4
0
//2.5 删除模板
func (this *YunpianAPI) TplDel(tpl_id int) error {
	req := httplib.Post(geturl(URL_TPL_DEL))
	req.Param("apikey", this.APIKey)
	req.Param("tpl_id", strconv.Itoa(tpl_id))
	baseStruct := BaseStruct{}
	req.ToJson(&baseStruct)
	if baseStruct.Code == 0 {
		return nil
	}
	return errors.New(baseStruct.Detail)
}
Example #5
0
//2.3 取模板
func (this *YunpianAPI) TplGet(tpl_id int) (Template, error) {
	req := httplib.Post(geturl(URL_TPL_GET))
	req.Param("apikey", this.APIKey)
	req.Param("tpl_id", strconv.Itoa(tpl_id))
	tpl := Tpl{}
	req.ToJson(&tpl)
	if tpl.Code == 0 {
		return tpl.Template, nil
	}
	return Template{}, errors.New(tpl.Detail)
}
Example #6
0
//2.2 添加模板
func (this *YunpianAPI) TplAdd(tpl_content string, notify_type int) (Template, error) {
	req := httplib.Post(geturl(URL_TPL_ADD))
	req.Param("apikey", this.APIKey)
	req.Param("tpl_content", tpl_content)
	req.Param("notify_type", strconv.Itoa(notify_type))
	tpl := Tpl{}
	req.ToJson(&tpl)
	if tpl.Code == 0 {
		return tpl.Template, nil
	}
	return Template{}, errors.New(tpl.Detail)
}
Example #7
0
//获取状态报告
func (this *YunpianAPI) VoicePullStatus(page_size ...int) ([]VoiceStatu, error) {
	req := httplib.Post(geturl(URL_VOICE_PULLSTATUS))
	req.Param("apikey", this.APIKey)
	if len(page_size) > 0 {
		req.Param("page_size", strconv.Itoa(page_size[0]))
	}
	voicepullstatus := VoicePullStatus{}
	req.ToJson(&voicepullstatus)
	if voicepullstatus.Code == 0 {
		return voicepullstatus.Voice_Status, nil
	}
	return nil, errors.New(voicepullstatus.Detail)
}
Example #8
0
//3.4 获取回复短信
func (this *YunpianAPI) SmsPullReply(page_size ...int) ([]SMSReply, error) {
	req := httplib.Post(geturl(URL_SMS_PULLREPLY))
	req.Param("apikey", this.APIKey)
	if len(page_size) > 0 {
		req.Param("page_size", strconv.Itoa(page_size[0]))
	}
	smspullreply := SMSPullReply{}
	req.ToJson(&smspullreply)
	if smspullreply.Code == 0 {
		return smspullreply.SMSReplys, nil
	}
	return nil, errors.New(smspullreply.Detail)
}
Example #9
0
//3.2 获取状态报告
func (this *YunpianAPI) SmsPullStatus(page_size ...int) ([]SMSStatu, error) {
	req := httplib.Post(geturl(URL_SMS_PULLSTATUS))
	req.Param("apikey", this.APIKey)
	if len(page_size) > 0 {
		req.Param("page_size", strconv.Itoa(page_size[0]))
	}
	smspullstatus := SMSPullStatus{}
	req.ToJson(&smspullstatus)
	if smspullstatus.Code == 0 {
		return smspullstatus.SMSStatus, nil
	}
	return nil, errors.New(smspullstatus.Detail)
}
Example #10
0
//4.1 发送语音验证码
func (this *YunpianAPI) VoiceSend(info VoiceSendInfo) (VoiceSendResult, error) {
	req := httplib.Post(geturl(URL_VOICE_SEND))
	req.Param("apikey", this.APIKey)
	req.Param("mobile", info.Mobile)
	req.Param("code", info.Code)
	req.Param("callback_url", info.Callback_URL)
	req.Param("display_num", info.Display_Num)
	voicesend := VoiceSend{}
	req.ToJson(&voicesend)
	if voicesend.Code == 0 {
		return voicesend.Result, nil
	}
	return VoiceSendResult{}, errors.New(voicesend.Detail)
}
Example #11
0
//3.8 指定模板发送
func (this *YunpianAPI) SmsTplSend(info SMSTplSendInfo) (SMSResult, error) {
	req := httplib.Post(geturl(URL_SMS_TPLSEND))
	req.Param("apikey", this.APIKey)
	req.Param("mobile", info.Mobile)
	req.Param("tpl_id", strconv.Itoa(info.Tpl_ID))
	req.Param("tpl_value", info.Tpl_Value)
	req.Param("extend", info.Extend)
	req.Param("uid", info.Uid)
	smstplsend := SMSSend{}
	req.ToJson(&smstplsend)
	if smstplsend.Code == 0 {
		return smstplsend.Result, nil
	}
	return SMSResult{}, errors.New(smstplsend.Detail)
}
Example #12
0
//3.9 批量个性化发送
func (this *YunpianAPI) SmsMultiSend(info SMSSendInfo) ([]SMSSend, error) {
	req := httplib.Post(geturl(URL_SMS_MULTISEND))
	req.Param("apikey", this.APIKey)
	req.Param("mobile", info.Mobile)
	req.Param("text", info.Text)
	req.Param("extend", info.Extend)
	req.Param("uid", info.Uid)
	req.Param("callback_url", info.Callback_URL)
	smssends := []SMSSend{}
	err := req.ToJson(&smssends)
	if err == nil {
		return smssends, nil
	}
	return nil, err

}
Example #13
0
//3.6 查看回复信息
func (this *YunpianAPI) SmsGetReply(info SMSGetReplyInfo) ([]SMSReply, error) {
	req := httplib.Post(geturl(URL_SMS_GETREPLY))
	req.Param("apikey", this.APIKey)
	req.Param("start_time", info.Start_Time)
	req.Param("end_time", info.End_Time)
	req.Param("page_num", strconv.Itoa(info.Page_Num))
	req.Param("page_size", strconv.Itoa(info.Page_Size))
	if info.Mobile != "" {
		req.Param("mobile", info.Mobile)
	}
	smsgetreply := SMSGetReply{}
	req.ToJson(&smsgetreply)
	if smsgetreply.Code == 0 {
		return smsgetreply.SMS_Replys, nil
	}
	return nil, errors.New(smsgetreply.Detail)
}
Example #14
0
//1.2 修改账户信息
func (this *YunpianAPI) UserSet(user UserSetInfo) error {
	req := httplib.Post(geturl(URL_USER_SET))
	req.Param("apikey", this.APIKey)
	if user.AlarmBalance != 0 {
		req.Param("alarm_balance", strconv.Itoa(user.AlarmBalance))
	}
	if user.EmergencyContact != "" {
		req.Param("emergency_contact", user.EmergencyContact)
	}
	if user.EmergencyMobile != "" {
		req.Param("emergency_mobile", user.EmergencyMobile)
	}
	baseStruct := BaseStruct{}
	req.ToJson(&baseStruct)
	if baseStruct.Code == 0 {
		return nil
	}
	return errors.New(baseStruct.Detail)
}
Example #15
0
//3.1 智能匹配模板发送
func (this *YunpianAPI) SmsSend(info SMSSendInfo) (SMSResult, error) {
	req := httplib.Post(geturl(URL_SMS_SEND))
	req.Param("apikey", this.APIKey)
	req.Param("mobile", info.Mobile)
	req.Param("text", info.Text)
	if info.Extend != "" {
		req.Param("extend", info.Extend)
	}
	if info.Uid != "" {
		req.Param("uid", info.Uid)
	}
	if info.Callback_URL != "" {
		req.Param("callback_url", info.Callback_URL)
	}
	send := SMSSend{}
	req.ToJson(&send)
	if send.Code == 0 {
		return send.Result, nil
	}
	return SMSResult{}, errors.New(send.Detail)
}