我创建了一个带有自定义菜单项的时间线卡。当用户选择该菜单项时,我想得到一个回调。
// Create a menu item for the card
var mnuActivate = new MenuItem() {
Action = "CUSTOM",
RemoveWhenSelected = new bool?(true),
Id = ACCEPT_ID,
Values = new List<MenuValue>() {
new MenuValue() {
State="DEFAULT",
DisplayName="Activate",
},
new MenuValue() {
State="PENDING",
DisplayName="Activating..."
},
new MenuValue() {
State="CONFIRMED",
DisplayName="Activated"
}
}
}
// Create a new card for the user's timeline
var item = new TimelineItem() {
Html = html,
Notification = new NotificationConfig() { Level = "DEFAULT" },
MenuItems = new List<MenuItem>() { mnuActivate }
};
var card = this._service.Timeline.Insert(item).Fetch();
然后我订阅所有时间线事件并提供一个 https 回调 URL
// Create a new subscription
var subscription = new Subscription()
{
Collection = "timeline",
Operation = new List(),
CallbackUrl = "https://mypubliclyavailableserver.com/notify"
};
this._service.Subscriptions.Insert(subscription).Fetch();
// Retrieve a list of subscriptions to make sure it is there.
var mySubcriptions = this._service.Subscriptions.List().Fetch();
if (mySubcriptions != null && mySubcriptions.Items != null && mySubcriptions.Items.Count == 1)
{
Console.WriteLine("Subscription created successfully.");
}
因此,据我所知,订阅的创建没有任何问题。但是在与卡交互后,我从未收到回调。我错过了什么?
我尝试过的事情:
- 在订阅 obj、时间线卡和 menuItem 上填充 Id
- 在创建卡之前而不是之后订阅
- 在订阅对象上添加 userId 作为 UserToken
- 直接调用我的回调 URL 以确保它正在监听
来自 GET /mirror/v1/subscriptions 的 JSON 响应:
{
"kind": "mirror#subscriptionsList",
"items": [
{
"kind": "mirror#subscription",
"id": "timeline",
"updated": "2013-10-28T15:19:19.404Z",
"collection": "timeline",
"callbackUrl": "https://mypubliclyavailableserver.com/notify"
}
]
}