=== maemual @ 2024-03-22T06:42:29Z === 近期卡片新特性较多,人力比较紧张,还在推进中。 可以继续使用旧版的卡片回传交互使用。 === Martin2877 @ 2024-06-21T02:13:35Z === 卡片回调一直报这个错误 `json: cannot unmarshal string into Go struct field CardAction.Header of type []string]` === sbaby1997 @ 2024-07-31T13:45:20Z === 这个问题非常影响使用呀! === maemual @ 2024-07-31T13:53:03Z === @sbaby1997 升级最新版 v3.3.0,然后卡片回传交互选“卡片回传交互(旧)” === Martin2877 @ 2024-08-02T01:54:18Z === All right. 鉴于官方还没修,我这里提出一个临时解决方法,大家可以参考: 在 `package larkcard` 文件中 1. 修改 `model.go` 中的 `CardAction` ```go type CardAction struct { *larkevent.EventReq Schema string `json:"schema"` Header struct { EventID string `json:"event_id"` Token string `json:"token"` CreateTime string `json:"create_time"` EventType string `json:"event_type"` TenantKey string `json:"tenant_key"` AppID string `json:"app_id"` } `json:"header"` Challenge string `json:"challenge"` Token string `json:"token"` Type string `json:"type"` Event struct { Operator struct { TenantKey string `json:"tenant_key"` UserID string `json:"user_id"` OpenID string `json:"open_id"` UnionID string `json:"union_id"` } `json:"operator"` Token string `json:"token"` Action struct { Tag string `json:"tag"` Timezone string `json:"timezone"` FormValue map[string]string `json:"form_value"` Name string `json:"name"` } `json:"action"` Host string `json:"host"` Context struct { OpenMessageID string `json:"open_message_id"` OpenChatID string `json:"open_chat_id"` } `json:"context"` } `json:"event"` } ``` 2. 修改`card.go`中的 `VerifySign`方法,使用 eventEncryptKey ```go if h.eventEncryptKey == "" { return nil } ... targetSign := Signature(requestTimestamp, requestNonce,h.eventEncryptKey,string(req.Body)) ``` 3. 修改`card.go`中的 `Signature` 方法,使用 sha256加密 ```go h := sha256.New() ``` === crazykun @ 2024-09-14T02:43:54Z === 新的改成event事件承载了 [v3代码示例](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/sample/event/event.go#L171) ``` .OnP2CardActionTrigger(func(ctx context.Context, event *callback.CardActionTriggerEvent) (*callback.CardActionTriggerReponse, error) { fmt.Println("receive card action") fmt.Println(larkcore.Prettify(event)) return nil, nil }) ``` === kj648 @ 2025-01-23T11:52:59Z === 对于卡片消息回调的 Value 应该定义成interface{} . 至少目前的卡片消息回调, 回调事件的值 支持 字符串,如果用字符串传进来 就直接cannot unmarshal string into Go struct XXXXXXX 。为了不出发这个error 只能强制使用 对象结构作为value event *callback.CardActionTriggerEvent ```go type CallBackAction struct { Value map[string]interface{} `json:"value"` Tag string `json:"tag"` Option string `json:"option"` Timezone string `json:"timezone"` Name string `json:"name"` FormValue map[string]interface{} `json:"form_value"` InputValue string `json:"input_value"` Options []string `json:"options"` Checked bool `json:"checked"` } ``` === xiaozhi747 @ 2025-03-14T09:53:22Z === 还没修复么? === maemual @ 2025-03-14T10:12:24Z === @xiaozhi747 早就支持了新版卡片回调,建议按照 README 文档使用。 === eyotang @ 2025-11-24T04:13:19Z === > 卡片回调一直报这个错误 `json: cannot unmarshal string into Go struct field CardAction.Header of type []string]` v3.4.3也有这个问题,请问怎么解决的?header是map[string]string,但是sdk里面定义的是map[string][]string