使用Swift从模板发送大量语音

使用Swift向一组座机或手机发送批量语音消息(文本到语音)


例子中 Swift:

let aclass : String = "voice";
let method : String = "sendvoicetogroupfromtemplate";
let user : String = "user";
let password : String = "password";
let countrycode : String = "34";
let idgroup : String = "1";
let idtemplate : String = "1000";
let scheduledatetime : String = "";
let output : String = "";
let urlPath: String = "https://www.afilnet.com/api/http/?class="+aclass+"&method="+method+"&user="+user+"&password="+password+"&countrycode="+countrycode+"&idgroup="+idgroup+"&idtemplate="+idtemplate+"&scheduledatetime="+scheduledatetime+"&output="+output

let url: NSURL = NSURL(string: urlPath)!
let request1: NSURLRequest = NSURLRequest(url: url as URL)
let queue:OperationQueue = OperationQueue()

NSURLConnection.sendAsynchronousRequest(request1 as URLRequest, queue: queue, completionHandler:{ (response: URLResponse?, data: Data?, error: Error?) -> Void in
	do {
		if let jsonResult = try JSONSerialization.jsonObject(with: data!, options: []) as? NSDictionary {
			// Do something with result
		}

	} catch let error as NSError {
		print(error.localizedDescription)
	}
})



请参阅以下示例:

PHP Java C sharp Unix Ruby on Rails Python Android Objective C / iPhone SQL Server Oracle Node JS Go Scala Swift


使用模板将文本语音转换发送给一组收件人


参数描述必修/可选
class=voice要求的课程:要求的课程必修
method=sendvoicetogroupfromtemplate请求的类方法:发出请求的类的方法必修
user您的Afilnet帐户的用户和电子邮件必修
password您的Afilnet帐户的密码必修
countrycodevoice.sendvoicetogroupfromtemplate_countrycode必修
idgroupvoice.sendvoicetogroupfromtemplate_idgroup必修
idtemplatevoice.sendvoicetogroupfromtemplate_idtemplate必修
scheduledatetimevoice.sendvoicetogroupfromtemplate_scheduledatetime可选的
output结果的输出格式可选的

发出请求时,您将收到以下字段:

  •  status
  •  结果(如果status = success),您将在此处收到以下值:
    • id
    • count
    • credits
    • destinations
      • messageid
      • destination
  •  错误(如果status = error),在这里您将收到错误代码

下面列出了可能的错误代码

描述
MISSING_USER不包括用户或电子邮件
MISSING_PASSWORD不包含密码
MISSING_CLASS不包括课程
MISSING_METHOD不包括方法
MISSING_COMPULSORY_PARAM不包括强制参数
INCORRECT_USER_PASSWORD用户或密码错误
INCORRECT_CLASS班级不正确
INCORRECT_METHOD方法不正确
NOT_ACCESS_TO_GROUP不允许您进入指定的组
NO_CREDITS您的余额不足
参数:
  • class: voice
  • method: sendvoicetogroupfromtemplate
  • user: user
  • password: password
  • countrycode: 34
  • idgroup: 1
  • idtemplate: 1000
  • scheduledatetime:
  • output:
请求:
https://www.afilnet.com/api/http/?class=voice&method=sendvoicetogroupfromtemplate&user=user&password=password&countrycode=34&idgroup=1&idtemplate=1000&scheduledatetime=&output=
有关Cookie的重要信息:如果您继续使用本网站,我们将假定您接受使用条款。您可以在我们的Cookies政策中找到更多信息. 继续