0

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

为此,我需要为 Swift 使用一个名为“Perfect cURL”的包,它可以在服务器端 swift 上运行。

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

我要发送的 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))

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

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

是否有人熟悉 Perfect cURL 或知道如何快速执行此操作?

提前致谢。

4

1 回答 1

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

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

于 2017-10-11T14:30:04.883 回答