推送通知的空响应 [英] Empty response from push notification

查看:51
本文介绍了推送通知的空响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Google云端硬盘推送通知API中收到了空的响应帖子.我不确定我是在看向收听应用程序发布的数据的方式是否不正确,还是在设置频道方面有误.

I'm getting empty response posts from google drive push notification api. I'm not sure if I'm not looking correctly at the posted data to my listening app or if I'm incorrectly setting up my channels.

我已经能够设置通过以下方式验证的频道:

I've able to setup channels verified with the responses like:

[14-07-26 14:27:19:697 EDT] {
 "kind": "api#channel",
 "id": "ce976221-7f6c-44bd-82f3-6a7a539fbc18",
 "resourceId": "YTWyD_gD_mUUBM8Ttrqc6P6ZCxI",
 "resourceUri": "https://www.googleapis.com/drive/v2/files/1T0GX4lBx6yH2DHMAS624qk5bQylZm1kRs_rE8tIHS_c?updateViewedDate=false&alt=json",
 "token": "caller=https://script.google.com/a/macros/ccsknights.org/s/AKfycbxc0JwGl-TptxgsHhWPaAZbIgQXRk7fhB282ReOa09f_6HmGPkw/exec",
 "expiration": "1406402836000"
}

当我弄乱测试文档时,我的听力应用程序确实会收到通知.我对所有已发布的数据进行了转储,但显示为:

And my listening app does receive notifications as I mess with the test document. I do a dump of the entire posted data but it shows up as:

{queryString = null,参数= {},contextPath =,参数= {},contentLength = 0}

{queryString=null, parameter={}, contextPath=, parameters={}, contentLength=0}

我已经将其他数据发布到应用程序中进行测试,并且它会按预期显示:

I've posted other data to the app to test it and it shows up as expected:

{queryString = bob/asdasd/asdasdsd/adsad,postData = FileUpload,参数= {test =是,test2 =否,bob/asdasd/asdasdsd/adsad =},contextPath =,参数= {test = [Ljava.lang.Object; @ 2fc540bd,test2 = [Ljava.lang.Object; @ 3f1d50cb,bob/asdasd/asdasdsd/adsad = [Ljava.lang.Object; @ 1da35fcc},contentLength = 17}

{queryString=bob/asdasd/asdasdsd/adsad, postData=FileUpload, parameter={test=yes, test2=no, bob/asdasd/asdasdsd/adsad=}, contextPath=, parameters={test=[Ljava.lang.Object;@2fc540bd, test2=[Ljava.lang.Object;@3f1d50cb, bob/asdasd/asdasdsd/adsad=[Ljava.lang.Object;@1da35fcc}, contentLength=17}

听力应用程序很简单:

var sslog = SpreadsheetApp.openById('1dOic6cWtTuj7lxi-QoRK2hrlXArd2C5ZlqOEmCvJ6R0').getSheets()[0];

function doPost(e) {
 sslog.appendRow([e]);
  return 200;
  //return ContentService.createTextOutput().setContent(JSON.stringify(e)).setMimeType(ContentService.Mi    meType.JSON);
}

我缺少一些东西可以从帖子中提取推送通知数据吗?

Is there something I'm missing to be able to extract the push notification data from the post?

推荐答案

正确的答案是在postData对象中检索了帖子正文.它已添加但未记录.您可以在以下网址找到有关此内容的更多信息: https://developers.google.com/apps-script/releases/2013

The correct answer is the post body is retrieved in the postData object. It was added but not documented. You can find more about it at: https://developers.google.com/apps-script/releases/2013

function doPost(e) {
Logger.log(e.postData.getDataAsString());
}

这篇关于推送通知的空响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆