如何测试Mirror API订阅 [英] How to test Mirror API Subscriptions

查看:89
本文介绍了如何测试Mirror API订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https callbackUrl的限制以及整个订阅的性质使得这似乎只能用可公开访问的URL来完成.

The restrictions of a https callbackUrl and the nature of the subscriptions as a whole makes it seem like this is something that can only be done with a publicly accessible url.

到目前为止,我遇到了两个潜在的解决方案,以简化本地开发/调试.

So far I have come across two potential solutions to make local development / debugging easier.

第一个是Google提供的订阅代理服务.实际上,此解决方法使您可以删除SSL限制和对自定义URL的代理订阅回调.

The first is the Subscription Proxy service offered by google. This workaround essentially lets you remove the SSL restriction and proxy subscription callbacks to a custom URL.

我发现在本地进行开发的第二种也是最有用的方法是将订阅回调请求(例如从可公开访问的服务器中捕获)捕获到日志中,然后使用curl在本地/dev机器上重现该请求使用类似的东西:

The second and most helpful way I have found to do development locally is to capture a subscription callback request (say from a server that is publicly accessible) into a log and then use curl to reproduce that request on your local/dev machine using something like:

curl -H "Content-type: application/json" -X POST \
  -d '{"json for":"the notification"}' http://localhost:8080/notify

由于请求有时可能很大,或者您可能想测试多种回调类型,所以我还发现将下标请求的JSON放入各种文件(例如:timeline-respond.json)然后运行

Since the requests can sometimes be large, or you might want to test multiple callback types, I also found it useful to put the JSON of the subscript request into various files (ex: timeline-respond.json) and then run

curl -H "Content-Type: application/json" \
  --data @timeline-respond.json http://localhost:8080/notify

我很好奇其他人正在做什么以在本地测试其应用程序订阅.

I'm curious as to what other people are doing to test their application subscriptions locally.

推荐答案

您提到的命令行卷曲技术是迄今为止我发现的最好的技术.

The command line curl technique that you mention is the best I've found to date.

我已经尝试了其他解决方案,例如与本地脚本配对的App Engine订阅目标,该脚本将App Engine服务拉到新通知以中继到localhost,但是到目前为止,我还没有找到值得的解决方案增加的复杂性.

I've experimented with other solutions, such as an App Engine subscription target paired with a local script which pulls that App Engine service for new notifications to relay to localhost, but so far I haven't found one that's worth the added complexity.

或者,有许多可用的localhost代理.我最喜欢的是 ngrok.com .

Alternatively, there are many localhost proxies available. My favorite is ngrok.com.

这篇关于如何测试Mirror API订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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