2017-10-08 41 views
0

我一直在試圖製作一個服務器端的Swift程序,它使用Parse的cURL調用從Parse下載JSON數據。解析完美CURL Swift

爲了這個工作,我需要使用一個名爲「Perfect cURL」的Swift包,它在服務器端swift上工作。

我無法翻譯其中一個查詢來使用Perfect 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 

這是我已經能夠將其轉換爲使用完美捲曲

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}' \ 

是否有人熟悉Perfec t cURL還是有任何關於如何迅速做到這一點的知識?

在此先感謝。

回答

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頻道以獲得即時反饋。

+0

完美,正是我所需要的,現在就加入鬆弛頻道,謝謝! – Johno2110