سؤال

Is it possible to specify a payload in arbitrary fields in a menu item? Right now, I’m passing them as the id for the menu (which works but feels hacky) but I notice that if I set them as fields of the menu item, I never receive them in the POST:

    MenuItem menuItem = new MenuItem()
            // ... bunch skipped
            .setId("5141...")
            .set("eventId", "eventIdGoesHere")
            ;

Here is what I receive in the callback URL: I see the id in the payload field but I don’t see any "eventId" in the body of the POST:

body: {
 "collection": "timeline",
 "itemId": "a11d33c2-32d8-49c7-989e-2b69814e260f",
 "operation": "UPDATE",
 "userToken": "ya29.1....",
 "userActions": [
  {
   "type": "CUSTOM",
   "payload": "5141..."
  }
 ]
}
هل كانت مفيدة؟

المحلول

You found the best practice - the ID of the menu item is returned as the payload of the user action when it is sent to you. The ID is opaque, so you are free to set it to whatever values you wish to decode however you want to.

Since the timeline itemId is also sent to you, you may also wish to set the sourceItemId or other (defined) attributes on the original timeline item to values that may contain information that will be useful to you. You can then do a timeline.get on the item to fetch this additional information.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top