我正在基于我的ios应用程序中的Save事件在后台云代码中生成自定义Parse Analytic事件。我也可以在Parse.com的Analytic面板中看到它。 如何在我的ios应用程序中访问它? 我尝试
时出现以下错误Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo=0x7a9697e0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7a956d00> { URL: https://api.parse.com/1/events/commentsAnalytics } { status code: 400, headers {
"Access-Control-Allow-Methods" = "*";
"Access-Control-Allow-Origin" = "*";
Connection = "keep-alive";
"Content-Length" = 36;
"Content-Type" = "application/json; charset=utf-8";
Date = "Fri, 23 Jan 2015 06:43:38 GMT";
Server = "nginx/1.6.0";
"X-Parse-Platform" = G1;
"X-Runtime" = "0.007086";
} }, NSErrorFailingURLKey=https://api.parse.com/1/events/commentsAnalytics, NSLocalizedDescription=Request failed: bad request (400),
答案 0 :(得分:1)
检查您是否在密钥 (X-Parse-Application-Id和X-Parse-REST-API-Key) >请求标题。以下是Alamofire的一个例子。
var request = NSMutableURLRequest(URL: NSURL(string: "https://api.parse.com/1/events/Buy")!)
request.HTTPMethod = "POST"
request.setValue("<APPLICATION-KEY>", forHTTPHeaderField: "X-Parse-Application-Id")
request.setValue("<REST-KEY>", forHTTPHeaderField: "X-Parse-REST-API-Key")
var parameter: NSDictionary = ["dimensions" :["product" : ["name" : "macpro", "price" : "350"]]]
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(parameter, options: nil, error: nil)
Alamofire.request(request).response { (request, response, result, error) -> Void in
// handle response
println("\(request) \t \(response) \t \(result) \t \(error) ")
}
要检查事件,请转到解析中的应用程序面板...
...点击“自定义细分”...
并自定义图表。