나는 아래 parse.com 휴식 API의 예를 복제하는 것을 시도하고 데이터 인코딩을 사용하는 방법 : 그래서사용 Parse.com REST API를 - CURL
curl -X GET \
-H "X-Parse-Application-Id: APP_ID" \
-H "X-Parse-REST-API-Key: API_KEY" \
-G \
--data-urlencode 'where={"playerName":"John"}' \
https://api.parse.com/1/classes/GameScore
을 기반으로 내가 그렇게 전화
var https = require("https");
exports.getJSON = function(options, onResult){
var prot = options.port == 443 ? https : http;
var req = prot.request(options, function(res){
var output = '';
res.setEncoding('utf8');
res.on('data', function (chunk) {
output += chunk;
});
res.on('end', function() {
var obj = JSON.parse(output);
onResult(res.statusCode, obj);
});
});
req.on('error', function(err) {
});
req.end();
};
:
var options = {
host: 'api.parse.com',
port: 443,
path: '/1/classes/GameScore',
method: 'GET',
headers: {
'X-Parse-Application-Id': 'APP_ID',
'X-Parse-REST-API-Key': 'APP_KEY'
}
};
rest.getJSON(options,
function(statusCode, result)
{
// I could work with the result html/json here. I could also just return it
//console.log("onResult: (" + statusCode + ")" + JSON.stringify(result));
res.statusCode = statusCode;
res.send(result);
});
내 질문에 유래에서 발견 예에, 나는 기능을 구현 "{-"playerName ":"Sean Plott ","cheatMode ": false} '비트를"- data-urlencode "로 보내려면 어떻게해야합니까? 나는 '/ 1/classes/GameScore? playerName = John'과 같은 옵션에 경로를 설정하여 경로에 추가하려고 시도했지만 작동하지 않았다. John의 게임 스코어가 아닌 GameScore를 모두 받았다.
왜 그냥 공식 구문 분석 자바 스크립트 SDK를 사용하지 않는? 또한 소스 코드를보고 나머지 API를 사용하는 방법을 볼 수 있습니다. https://npmjs.org/package/parse – bklimt