我试着用钛板做这个卷曲帖子,但是我一直收到一个400错误。我尝试将数据作为Javascript对象进行传递。我还尝试更改了标题。也许我没有找到正确的组合。请帮帮忙。
curl 'https://ortc-mobilepush.realtime.co/mp/publish' --data-binary '{"applicationKey": "[INSERT_YOUR_APP_KEY]","privateKey": "[INSERT_YOUR_PRIVATE_KEY]",
"channel" : "NewArticles",
"message" : "We have new articles for you",
"payload" : "{ \"sound\" : \"default\", \"badge\" : \"2\" }" }'
var url = 'https://ortc-mobilepush.realtime.co/mp/publish';
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e);
//alert('error');
},
timeout : 5000 // in milliseconds
});
client.open("POST", url);
client.setRequestHeader('Content-Type', 'multipart/form-data');
// Send the request.
var text = '{"applicationKey": "[App Key]","privateKey": "[Private key]", "channel" : "GlobalChanell", "message" : "test", "payload" : "{ \"sound\" : \"default\", \"badge\" : \"32\" }" }';
client.send(text);发布于 2014-04-25 19:16:27
最近,我在一个客户端应用程序中也遇到了同样的问题……所以我应该给出解决方案..
可能是服务器url...so有问题,您可以尝试更改该url,并将其替换为以下内容...
https://exampleserver.com/mp/publish
然后将Content-Type设置为application/json并创建json对象,如下所示...
var text = {
applicationKey : [key],
privateKey : [p_key],
etc....
}然后像这样传递它。
Client.send(JSON.stringify(文本));
https://stackoverflow.com/questions/23287855
复制相似问题