用 Perfect CURL 解析 Swift

Parse with Perfect CURL Swift

我一直在尝试制作服务器端 Swift 程序,该程序使用 Parse 的 cURL 调用从 Parse 下载 JSON 数据。

为此,我需要为 Swift 使用一个名为 "Perfect cURL" 的包,该包在服务器端 swift 上运行。

我无法翻译其中一个查询以使用 Perfect cURL。我目前能够做的是使用调用从 Parse 下载整个 class 数据,但无法发送条件。

我要发送的 cURL 在 Parse 中看起来像这样

curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'where={"playerName":"Sean Plott","cheatMode":false}' \
https://api.parse.com/1/classes/GameScore

这就是我能够使用 Perfect cURL 将其转换的结果

let url = serverURL
let custom = CURLRequest.Header.Name.custom(name: "X-Parse-Application-Id")
let custom2 = CURLRequest.Header.Name.custom(name: "X-Parse-REST-API-Key")
let custom3 = CURLRequest.Header.Name.custom(name: "Content-Type")
let appIDS = "\(appID)"
let clientKeyS = "\(clientKey)"
let content = "application/json"


let request = CURLRequest(url,   .addHeader(custom, appIDS),   
                                 .addHeader(custom2, clientKeyS),  
                                 .addHeader(custom3, content), 
                                 .httpMethod(.get))

这生成的是整个 class 的 JSON 数据,但我希望能够添加条件

-G \
--data-urlencode 'where={"playerName":"Sean Plott","cheatMode":false}' \

是否有人熟悉 Perfect cURL 或了解如何在 swift 中执行此操作?

提前致谢。

let serverURL = "https://api.parse.com/1/classes/GameScore"
let query = "where={\"playerName\":\"Sean Plott\",\"cheatMode\":false}"
let url =  serverURL + "?" + query.stringByEncodingURL

您可以加​​入 Perfect slack 频道以获得即时反馈。