2016-03-04 109 views
0

成功登录,授权和检索访问令牌后,我想通过foursquare API检查当前用户进入会场。根据文档,只有一个“venueId”的必需参数,我可以在搜索场馆方法中成功检索。文档还说,oauth标记需要包含在请求中,所以我也包括了这个。Foursquare API检查Alamofire请求的问题

令牌字符串是正确的,我检查过,所以是venueId,但我仍然得到这个...我不知道为什么,但我已经做了我应该做的一切,有任何想法吗?

SUCCESS: { 
meta =  { 
    code = 400; 
    errorDetail = "Missing access credentials. See https://developer.foursquare.com/docs/oauth.html for details."; 
    errorType = "invalid_auth"; 
}; 
response =  { 
}; 

}

的方法检查...里面(就像我说的,标记字符串是存在的,正确的,因为是venueId)

if let tokenStr = NSUserDefaults.standardUserDefaults().objectForKey("tokenKey") as? String { 

     print("Checkin token string: \(tokenStr)") 

     Alamofire.request(.POST, "https://api.foursquare.com/v2/checkins/add", parameters: ["venueId" : "\(self.nearestPlaceID!)", "oauth_token" : "\(tokenStr)"], encoding: .JSON, headers: nil).responseJSON(completionHandler: { (response) -> Void in 

      print(response.request) 

      print(response) 
     }) 

    } 

感谢您的帮助!

回答

0

我觉得它需要“v”和“m”参数以及内容类型头文件!

Alamofire.request(.POST, "https://api.foursquare.com/v2/checkins/add", parameters: ["venueId" : "\(self.nearestPlaceID!)", "oauth_token" : "\(tokenStr)", "v" : "\(foursquareVersion)", "m" : "foursquare"], headers: ["Content-type" : "application/x-www-form-urlencoded"]).responseJSON(completionHandler: { (response) -> Void in 

      print(response.request) 

      print(response) 
     })