我需要将其转换为ajax。
curl -X POST \
-H "X-Parse-Application-Id: ****************" \
-H "X-Parse-REST-API-Key: ******************" \
-H "Content-Type: application/json" \
-d '{
"deviceType": "ios",
"deviceToken": "result" ,
"channels": [
""
]
}' \
https://api.parse.com/1/installations
答案 0 :(得分:0)
我发现解决方案是创建一个ajax post方法。因此,在此示例中,您将执行以下ajax方法。
var headers = {
"X-Parse-Application-Id":"Your ID",
"X-Parse-REST-API-Key":"Your Rest API Key"
};
// Convert data object to JSON string:
var userData = { "deviceType": "the device or the variable that says the device",
"deviceToken": "The Token itself or the variable with the token",
"channels": [""]
};
var data = JSON.stringify(userData);
$.ajax({
headers: headers,
type: 'POST',
url: "https://api.parse.com/1/installations",
contentType: "application/json",
data: data,
dataType:"json",
success:function(data) {
// We log the responce from the server just to check.
alert("data:" + JSON.stringify(data) + " status: " + status);
},
error:function(data) {
// Show error message:
alert("Your data didn't save!" + JSON.stringify(data));
}
});