使用Swift将活动添加到群组
使用Swift在群组中创建活动
Swift : API文档
使用Swift将活动添加到群组
let aclass : String = "event";
let method : String = "addevent";
let user : String = "user";
let password : String = "password";
let idgroup : String = "1000";
let idtemplate : String = "1000";
let channel : String = "sms";
let time : String = "10";
let timetype : String = "d";
let urlPath: String = "https://www.afilnet.com/api/http/?class="+aclass+"&method="+method+"&user="+user+"&password="+password+"&idgroup="+idgroup+"&idtemplate="+idtemplate+"&channel="+channel+"&time="+time+"&timetype="+timetype
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)
}
})
let aclass : String = "event";
let method : String = "addevent";
let user : String = "user";
let password : String = "password";
let idgroup : String = "1000";
let idtemplate : String = "1000";
let channel : String = "sms";
let time : String = "10";
let timetype : String = "d";
let urlPath: String = "https://www.afilnet.com/api/http/"
let url: NSURL = NSURL(string: urlPath)!
let request1: NSMutableURLRequest = NSMutableURLRequest(url: url as URL)
request1.httpMethod = "POST"
let stringPost="class="+aclass+"&method="+method+"&user="+user+"&password="+password+"&idgroup="+idgroup+"&idtemplate="+idtemplate+"&channel="+channel+"&time="+time+"&timetype="+timetype
let data = stringPost.data(using: String.Encoding.utf8)
request1.timeoutInterval = 60
request1.httpBody=data
request1.httpShouldHandleCookies=false
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 Error {
print(error.localizedDescription)
}
参数 | 描述 | 必修/可选 |
---|---|---|
class=event | 要求的课程:要求的课程 | 必修 |
method=addevent | 请求的类方法:发出请求的类的方法 | 必修 |
user | 您的Afilnet帐户的用户和电子邮件 | 必修 |
password | 您的Afilnet帐户的密码 | 必修 |
idgroup | 组号 | 必修 |
idtemplate | 范本编号 | 必修 |
channel | 活动使用的频道(SMS,WhatsAPP,电子邮件,社交) | 必修 |
time | 天,周,月或年的数字 | 必修 |
timetype | 时间类型(可能的值:天,周,月或年) | 必修 |
发出请求时,您将收到以下字段:
- status
-
结果(如果status = success),您将在此处收到以下值:
- 没有其他值会发送给您
- 错误(如果status = error),在这里您将收到错误代码
下面列出了可能的错误代码
码 | 描述 |
---|---|
MISSING_USER | 不包括用户或电子邮件 |
MISSING_PASSWORD | 不包含密码 |
MISSING_CLASS | 不包括课程 |
MISSING_METHOD | 不包括方法 |
MISSING_COMPULSORY_PARAM | 不包括强制参数 |
INCORRECT_USER_PASSWORD | 用户或密码错误 |
INCORRECT_CLASS | 班级不正确 |
INCORRECT_METHOD | 方法不正确 |
NOT_ACCESS_TO_GROUP | 不允许您进入指定的组 |
INCORRECT_TIME_TYPE | 时间类型不正确(可能的值:天,周,月或年) |
TEMPLATE_NOT_EXISTS | 所选模板不存在 |
GROUP_NOT_EXISTS | 所选的群组不存在 |
EVENT_ALREADY_EXISTS | 同一频道和同一时间段已经存在一个事件 |
参数:
- class : event
- method : addevent
- user : user
- password : password
- idgroup : 1000
- idtemplate : 1000
- channel : sms
- time : 10
- timetype : d
请求:
https://www.afilnet.com/api/http/?class=event&method=addevent&user=user&password=password&idgroup=1000&idtemplate=1000&channel=sms&time=10&timetype=d