line-bot-sdk-go icon indicating copy to clipboard operation
line-bot-sdk-go copied to clipboard

Cannot give backgroundColor to flex message

Open afifmakarim opened this issue 5 years ago • 2 comments

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)

image

i got error when give a backgroundColor to flex message, it works normal when give a text color. is there anyone have same issue?

afifmakarim avatar Mar 10 '20 12:03 afifmakarim

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 : Screen Shot 2563-09-28 at 14 17 42

But When i try to send flex with php script like curl it i got this it is what i want : Screen Shot 2563-09-28 at 14 18 54

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

poon1412 avatar Sep 28 '20 07:09 poon1412

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.

cjtim avatar Feb 07 '21 15:02 cjtim

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~

Yang-33 avatar Nov 17 '23 03:11 Yang-33

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".

Yang-33 avatar Nov 17 '23 04:11 Yang-33