Hi, I’m using the code below to send a simple tweet, but I keep getting the following error:
Error Domain=TWTRNetworkingErrorDomain Code=-1011 “Request failed: unauthorized (401)” UserInfo={NSLocalizedFailureReason=, TWTRNetworkingStatusCode=401, NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/update.json, NSLocalizedDescription=Request failed: unauthorized (401)}
I am using xCode 8 and Swift 3. I believe my application is setup correctly in Application Management in the dashboard. Any help would be GREATLY appreciated. I’ve been scouring the net for answer but have not been able to figure out what I’m doing wrong. Thanks!
if (Twitter.sharedInstance().sessionStore.session() != nil)
{
let store = Twitter.sharedInstance().sessionStore
if let userid = store.session()?.userID {
let client = TWTRAPIClient(userID: userid)
let tweetText = helpMessage + " " + (googleLink?.description)!
client.sendTweet(withText: tweetText, completion: { (tweet, error) in
print(error!)
})
}
}