This is my first question.
As a hobby, I make a bot by hitting LINE's Message API with python's line-bot-sdk (1.5.0).
The python version is 3.6.4.I am using a flash.flask.
I use heroku for the web server and Cloudinary for the image.
I'd like to send LINE carousel messages now, no matter how many times I try
LineBotApiError [A message(messages[0]) in the request body is invalid]
The error is only returned, but it doesn't work at all.
Place the source code.
for product in range(num):
rarity="★"*(int(lineup[product]["gear"]["rarity")+1)
dst_time=_unixtime2 datetime(lineup[product]["end_time"]) - now
dst_time=str(dst_time).split(".")[0][:-3]
thumbnail_url=lineup[product]["gear"]["thumbnail"]
rm_ext,_=os.path.splitext(thumbnail_url)
res_dic=__check_exist(rm_ext[1:])
ifres_dic is None:
r=requests.get(url=base_url+thumbnail_url, cookies=cookie, headers=header)
res_dic=uploader.upload(r.content, public_id=rm_ext[1:])
url = res_dic ["secure_url" ]
cc = CarouselColumn(\
title=f "{lineup[product]['gear']['name']}({rarity})#{lineup[product]['gear']['brand']['name']}", \
thumbnail_image_url=url,\
text=f"C{lineup[product]['price']}\nSkill: {lineup[product]['skill']['name']}\nProbability UP: {lineup[product]['gear']['brand']['frequent_skill']['name']}\nAfter: {dst_time}",\n
actions=[PostbackTemplateAction(label="Order", data=f"order_id={lineup[product]['id']}")]\
)
crs.append(cc)
ct=CarouselTemplate(columns=crs, image_aspect_ratio="square")
retval=TemplateSendMessage(alt_text="Lineup here!",template=ct)
I've been looking at SDK samples and source code many times, but I don't know exactly why it doesn't work.
I look forward to hearing from you.
python python3 heroku flask
I recommend you to print length of your title, text, and url.
some tips for you.
len(title)<40
len(text)<60
url must have https
should be able to debug.
cheers,
khan
© 2024 OneMinuteCode. All rights reserved.