POST CURL包含vbscript中的请求标头和有效负载

时间:2016-07-06 06:53:22

标签: curl parse-platform vbscript

我在parse.com上用云代码创建了一个项目。

现在我想创建一个VBScript来调用CURL,如下所示。

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://localhost:1337/parse/classes/GameScore

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{}' \
  http://localhost:1337/parse/functions/hello

在javascript中我们可以通过以下代码实现它。

Parse.initialize('myAppId','unused');
Parse.serverURL = 'https://whatever.herokuapp.com';

var obj = new Parse.Object('GameScore');
obj.set('score',1337);
obj.save().then(function(obj) {
  console.log(obj.toJSON());
  var query = new Parse.Query('GameScore');
  query.get(obj.id).then(function(objAgain) {
    console.log(objAgain.toJSON());
  }, function(err) {console.log(err); });
}, function(err) { console.log(err); });

如何使用VBScript for .vbs文件实现它?

1 个答案:

答案 0 :(得分:1)

请尝试以下代码。

strRequest="{""eventId"":""TOaDAOqueV""}"
EndPointLink = "http://X.X.X.X:1337/parse/functions/method"

dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",EndPointLink,false
http.setRequestHeader "Content-Type","application/json"
http.setRequestHeader "X-Parse-Application-Id","XXXXXXXXXXXXXXXXXXXXX"

msgbox "REQUEST : " & strRequest
http.send strRequest

If http.Status = 200 Then
    msgbox "RESPONSE : " & http.responseText
    responseText=http.responseText
else
    msgbox "ERRCODE : " & http.status
End If

部分取自HTTP GET in VBS <{3}}

的答案