你好,我正在使用Phonegap应用程序的Parse SDK,我正在尝试实现推送通知。我已经有一个插件,让我的设备令牌和安装id。我现在需要做的就是把数据发送给Parse。
有人知道如何在javascript中使用curl或将此curl语句转换为ajax吗?
curl -X POST
-H "X-Parse-Application-Id: 1234"
-H "X-Parse-REST-API-Key: 1234"
-H "Content-Type: application/json"
-d '{
"deviceType": "ios",
"deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"channels": [
""
]
}'
https://api.parse.com/1/installations
使用jquery可以实现以下
$.ajax({
url: "https://api.parse.com/1/installations",
method: "POST",
headers: {
"X-Parse-Application-Id: 1234"
"X-Parse-REST-API-Key: 1234"
"Content-Type: application/json"
},
data: {
"deviceType": "ios",
"deviceToken": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"channels": [""]
},
success: function(response){ /*whatever you want
to do with the response data*/
}
})