line-bot-sdk-go
line-bot-sdk-go copied to clipboard
Cannot give backgroundColor to flex message
System Informations
- Go version: 1.12.16
- OS:
Expected Behavior
Current Behavior
Steps to Reproduce
Logs
jsonString := `{
"type": "bubble",
"header": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "image",
"url": "https://giantbomb1.cbsistatic.com/uploads/scale_small/9/97089/2915098-main.jpg",
"size": "full",
"aspectMode": "cover",
"aspectRatio": "4:3",
"gravity": "center"
}
]
}
],
"paddingAll": "0px"
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"contents": [],
"size": "xl",
"wrap": true,
"text": "tkte",
"color": "#ffffff",
"weight": "bold"
},
{
"type": "text",
"text": "Release Date : 2016-08-18",
"color": "#ffffffcc",
"size": "sm"
},
{
"type": "text",
"text": "Platform : PC, PS4, Nintendo Switch",
"color": "#ffffffcc",
"size": "sm"
}
],
"spacing": "sm"
},
{
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"contents": [],
"size": "sm",
"wrap": true,
"margin": "lg",
"color": "#EC3D44",
"text": "The sixteenth mainline entry in the long-running Tales action-RPG series, following the exploits of a pirate named Velvet."
}
]
}
],
"paddingAll": "13px",
"backgroundColor": "#EC3D44",
"cornerRadius": "2px",
"margin": "xl"
}
]
}
],
"paddingAll": "20px",
"backgroundColor": "#EC3D44"
}
}`
contents, err := linebot.UnmarshalFlexMessageJSON([]byte(jsonString))
if err != nil {
return err
}
if _, err := app.bot.ReplyMessage(
replyToken,
linebot.NewFlexMessage("Flex message alt text", contents),
).Do(); err != nil {
return err
}[](url)

i got error when give a backgroundColor to flex message, it works normal when give a text color. is there anyone have same issue?
I just got the same issuse like you got i think all background , position , margin it isn't working
When i Sending Flex Massage with Go From Line SDK I got this :

But When i try to send flex with php script like curl it i got this it is what i want :

I use UnmarshalFlexMessageJSON(data []byte) before sending a message it simply like you code
I think background , position , margin i think each of it not working at all
I see you already use string of JSON, you should use http request via https://api.line.me/v2/bot/message/reply
reference
Unmarshal is not implement padding yet, I got this problem too.
messaging_api.UnmarshalFlexContainer(jsonString) is tested in https://github.com/line/line-bot-sdk-go/blob/5b2f50d7e1c8603649ca640224d23a25db751ccf/examples/kitchensink/server.go#L661-L815 from new version. Let's use this! We'll write the version here~
https://github.com/line/line-bot-sdk-go/releases/tag/v8.0.0 has been released, and it fixes the issue. Please use new modules like "github.com/line/line-bot-sdk-go/v8/linebot/messaging_api".