I need a way to get ACAccount
which is created, or taken by Twitter SDK
provided by Fabric
while login with:
Twitter.sharedInstance().logInWithCompletion { (session: TWTRSession?, error: NSError?) -> Void in
if let userSession = session {
}
else {
}
}
I need this account, to use while posting in background with SLRequest
. Without account
is not working.
If you are already using Twitter SDK, no need to deal with ACAccount anymore.
Just follow their instructions, and you can build a request manually: Build TW Request manually
Here is that code updated for 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)")
}
}
}
}