如何使用swift访问microsoft outlook API。我想使用microsoft outlook api允许用户搜索某个Outlook服务器中的人。搜索框架已经建立。我真的很困惑甚至如何访问服务器。代码主要来自咨询之前完成此操作的人员。这是我到目前为止的代码:
class ExchangeAPI {
func HTTPsendRequest(request: NSMutableURLRequest, callback: (String, String?) -> Void) {
//implementing core data
var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
var context: NSManagedObjectContext = appDel.managedObjectContext!
let ent = NSEntityDescription.entityForName("Emails", inManagedObjectContext: context)
var email = Emails(entity: ent! , insertIntoManagedObjectContext: context)
let task = NSURLSession.sharedSession().dataTaskWithRequest(
request,
completionHandler: {
data, response, error in
if error != nil {
callback("", error!.localizedDescription)
} else {
callback(
NSString(data: data!, encoding: NSUTF8StringEncoding)! as String,
nil
)
}
})
task.resume()
}
func HTTPGet(url: String, callback: (String, String?) -> Void) {
//implementing core data
var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
var context: NSManagedObjectContext = appDel.managedObjectContext!
let ent = NSEntityDescription.entityForName("Emails",inManagedObjectContext: context)
var email = Emails(entity: ent! , insertIntoManagedObjectContext: context)
var request = NSMutableURLRequest(URL: NSURL(string: url)!)
HTTPsendRequest(request, callback: callback)
request.URL = NSURL(string: "https://mail.SAP.com/EWS/Exchange.asmx")
request.HTTPMethod = "GET"
}
}
答案 0 :(得分:0)
答案 1 :(得分:0)
我发现麻省理工学院的学生有一个应用程序来帮助其他人了解如何使用API。它在github上,链接发布在下面。 https://github.com/OfficeDev/O365-iOS-Connect它是客观的或快速的。