Hello, I’m developing a application for iOS(Swift).
I’m afraid my expressions may be rude or hard to read, because I’m not so good at English.
Sorry for any inconvinience I may cause you.
I’m trying to make tweet with “Line Break”.
For example
Hello!
World!
So I tried to use Rest API via Fabric. But it doesn’t work.
My code is…
let endPoint = "https://api.twitter.com/1.1/statuses/update.json"
var clientError : NSError?
var tweetText = self.contentTextView.text
tweetText = tweetText.stringByReplacingOccurrencesOfString("\n", withString: "\n\r")
let params = ["status" : tweetText]
let request = Twitter.sharedInstance().APIClient.URLRequestWithMethod("POST", URL: endPoint, parameters: params, error: &clientError)
Twitter.sharedInstance().APIClient.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
if (connectionError == nil) {
print(“success")
}else {
print(“failure: \(connectionError)")
}
}
In this code, “contentTextView.text" is text which I want to tweet.
I tried to change line break code “\n”,”\r”,”\n\r”,"\r\n" and “%0D%0A”, but it didn’t work too.
Error message is…
failure: Optional(Error Domain=TwitterAPIErrorDomain Code=32 "Request failed: unauthorized (401)" UserInfo={NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/update.json, NSLocalizedDescription=Request failed: unauthorized (401), NSLocalizedFailureReason=Twitter API error : Could not authenticate you. (code 32)})
If contentTextView.text doesn’t contain “\n” (in other words single line), I can tweet correctly.
For example
Hello! World!
How can I do?
Thanks.