line / line-bot-sdk-python

LINE Messaging API SDK for Python
https://pypi.python.org/pypi/line-bot-sdk
Apache License 2.0
1.87k stars 962 forks source link

About the Imagemap question #645

Closed ArthurTech123 closed 5 days ago

ArthurTech123 commented 5 days ago

Bad code

    def Image_Test():
        mastor_id = General.Get_Env("MASTOR_ID") # get line_user_id
        base_url = "https://example.com/image/123.jpg"
        alt_text = "test"
        con_text = "text"
        base_size = ImagemapBaseSize(width = 2500,height=1686)
        action = ImagemapAction(type="message",area=ImagemapArea(x=0,y=0,width=2500,height=1686),label="label",text=con_text)
        imagemap_message = ImagemapMessage(baseUrl=base_url,altText=alt_text,baseSize=base_size,actions=[action])
        messaging_api.push_message(
            PushMessageRequest(
                to=mastor_id,
                messages=[imagemap_message]
            )
        )

When I try the code I got the above: HTTP response body: {"message":"The request body has 1 error(s)","details":[{"message":"May not be empty","property":"messages[0].actions[0].text"}]}

and I still try to use replace the con_text from "text" to TextMessage(text="text"), and still not work

ArthurTech123 commented 5 days ago
    def Image_Test():
        mastor_id = General.Get_Env("MASTOR_ID") # get line_user_id
        base_size = ImagemapBaseSize(width=2500, height=1686)
        imagemap_message = ImagemapMessage(
            base_url="https://example.com/image",
            alt_text="This is an imagemap",
            base_size = base_size,
            actions=[
                MessageImagemapAction(
                    text="Hello",
                    area=ImagemapArea(x=0, y=0, width=2500, height=1686)
                )
            ]
        )
        LineFunction().messaging_api.push_message(
                PushMessageRequest(
                    to=mastor_id,
                    messages=[imagemap_message]
                )
        )

I try to use another way to writer and it is work now I think I lost the MessageImagemapAction