如何使用Parse

时间:2016-01-29 08:42:29

标签: ios swift twitter parse-platform

我正在尝试在授权后在用户的时间轴上发布我的应用名称的推文。我正在尝试这个:

let tweet = "This tweet has been sent"
let tweetBody = NSString(format: "status=%@", tweet.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!)
tweetBody.stringByReplacingOccurrencesOfString("!", withString: "%21")

var url = NSURL(string: "https://api.twitter.com/1.1/statuses/update.json")
var tweetRequest = NSMutableURLRequest(URL: url!)
tweetRequest.HTTPMethod = "POST"
tweetRequest.HTTPBody
tweetBody.dataUsingEncoding(NSUTF8StringEncoding)

twitter?.signRequest(tweetRequest)

Alamofire.request(.POST, tweetRequest, encoding: .JSON).validate().responseJSON {
    response in

       switch response.result {
           case .Success:
               if let value = response.result.value {
                  let json = JSON(value)
                  print(json)
               }
           case .Failure(let error):
               print(error)
           }
      }

但它失败并返回400.如何修复我的代码并通过Parse发送推文?

更新

我可以将带有参数的Alamofire的推文发送到https://api.twitter.com/1.1/statuses/update.json吗?

0 个答案:

没有答案