如果您已经在使用 Twitter SDK,则无需再处理 ACAccount。
只需按照他们的指示,您就可以手动构建请求:手动
构建 TW 请求
这是为 Swift 2 更新的代码:
if let userID = Twitter.sharedInstance().sessionStore.session()?.userID {
let client = TWTRAPIClient(userID: userID)
let statusesShowEndpoint = "https://api.twitter.com/1.1/statuses/update.json"
var clientError : NSError?
let request = client.URLRequestWithMethod("POST", URL: statusesShowEndpoint, parameters: dictMessage, error: &clientError)
if let err = clientError {
print("Error: \(err)")
}
else {
client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
if (connectionError == nil) {
do {
if let dictTWData = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) as? [String: AnyObject] {
print("\(dictTWData)")
}
}
catch _ as NSError {
}
catch {
fatalError()
}
}
else {
print("Error: \(connectionError)")
}
}
}
}