在iOS Swift中提供的Uber身份验证提供了Uber无效的OAuth 2.0凭据

在iOS Swift中提供的Uber身份验证提供了Uber无效的OAuth 2.0凭据,第1张

在iOS Swift中提供的Uber身份验证提供了Uber无效的OAuth 2.0凭据

终于我做到了:)

我改变了下面的方法,它工作了

    func callRequestAPI(url:String){        var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()        var session = NSURLSession(configuration: configuration)        let params:[String: AnyObject] = [ "product_id" : selectedUberProductId, "start_latitude" : start_lat, "start_longitude" : start_lng, "end_latitude" : end_lat, "end_longitude" : end_lng]        let request = appDelegate.oauth.request(forURL: NSURL(string:url)!)        request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")        request.HTTPMethod = "POST"        var err: NSError?        request.HTTPBody = NSJSONSerialization.dataWithJSonObject(params, options: NSJSONWritingOptions.allZeros, error: &err)        let task = session.dataTaskWithRequest(request) { data, response, error in if let httpResponse = response as? NSHTTPURLResponse {     if httpResponse.statusCode != 202 {         println("response was not 202: (response)")         return     } } if (error != nil) {     println("error submitting request: (error)")     return } // handle the data of the successful response here var result = NSJSONSerialization.JSonObjectWithData(data, options: NSJSONReadingOptions.allZeros, error: nil) as! NSDictionary println(result) if let request_id: String = result["request_id"] as? String{     println(request_id) } if let driver: String = result["driver"] as? String{     println(driver) } if let eta: Int = result["eta"] as? Int{     println(eta) } if let location: String = result["location"] as? String{     println(location) } if let status: String = result["status"] as? String{     println(status) } if let surge_multiplier: Int = result["surge_multiplier"] as? Int{     println(surge_multiplier) } if let vehicle: String = result["vehicle"] as? String{     println(vehicle) }        }        task.resume()    }

这是我得到的响应,我上面的方法也给出了解析

{  driver = "<null>";  eta = 15;  location = "<null>";  "request_id" = "ea39493d-b718-429f-8710-00a34dcdaa93";  status = processing;  "surge_multiplier" = 1;  vehicle = "<null>";}

请享用



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5126601.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存