asternic / wuzapi

Simple RESTful API for WhatsApp in Golang (using the Whatsmeow multi device library)
MIT License
145 stars 73 forks source link

need help using tarker with "Image must be in png or jpeg and base64 encoded in embedded format" #53

Open hernanbozzano opened 2 weeks ago

hernanbozzano commented 2 weeks ago

Hi everyone

I've been trying to convert a jpeg image to send it through whastapp (using tasker in android).. unfortunately, i tried many ways of converting but never succeded, does anyone have an example o explanation more detailed as a hint?

thanks in advance hernan

lordacer0 commented 2 weeks ago

First you have to read the file in binary to a variable. Then you have to remove the \n line breaks from that variable. The result is the base64 encoding of the file. A question, do audio webhooks work for you? And if they work, could you tell me if you use docker or run Wuzapi locally? Thank you.

hernanbozzano commented 2 weeks ago

You are a genius lordcer0! the \n thing did the trick! however, i can't see the thumbnail before i download the image in my phone, the "preview".. did you manage to fix it?

unfortunately, my robot is not meant to download audios i receive so i can't give you any information about.. i will let you know if i incorporate that stuff to my project

lordacer0 commented 2 weeks ago

You are a genius lordcer0! the \n thing did the trick! however, i can't see the thumbnail before i download the image in my phone, the "preview".. did you manage to fix it?

unfortunately, my robot is not meant to download audios i receive so i can't give you any information about.. i will let you know if i incorporate that stuff to my project

If you correctly set the mimetype when sending, for example image/jpeg, a thumbnail of the image is displayed in WhatsApp before opening it. Regarding the audio webhooks, the only thing I would need is to know if the webhooks arrive (if Wuzapi reacts) when they send an audio and if this is how you implemented Wuzapi, whether locally or with Docker (I with Docker). Greetings.

hernanbozzano commented 2 weeks ago

in the API references https://github.com/asternic/wuzapi/blob/main/API.md#send-image-message the image/jpeg is already in the http request '{"Phone":"5491155554444","Caption":"Look at this", "Image":"data:image/jpeg;base64,iVBORw0KGgoAAAANSU..."}', are you talking about something else?

on the other hand, regarding your question, my project runs on android tasker app and my webhook alert does not trigger when an audio is received (i checked).. why dont you let the audios auto-download and grab them from the downloaded folder?

lordacer0 commented 2 weeks ago

in the API references https://github.com/asternic/wuzapi/blob/main/API.md#send-image-message the image/jpeg is already in the http request '{"Phone":"5491155554444","Caption":"Look at this", "Image":"data:image/jpeg;base64,iVBORw0KGgoAAAANSU..."}', are you talking about something else?

on the other hand, regarding your question, my project runs on android tasker app and my webhook alert does not trigger when an audio is received (i checked).. why dont you let the audios auto-download and grab them from the downloaded folder?

Exactly, by sending the image encoded in base64 and sending the mimetype correctly, it already shows the thumbnail in the received message. Regarding audio webhooks, I do not use "base" cell phones, only one session. Do you run Wuzapi on Android with Termux? I run it in Docker, I need to test it running locally.

hernanbozzano commented 2 weeks ago

unfortunately it does not shows the blurry image before the image is opened :(

yes, i run wuzapi on android with termux!

George-Seven commented 2 weeks ago

It's not the platform, it's because wuzapi doesn't have code to set thumbnail preview here - https://github.com/asternic/wuzapi/blob/99879886604546de9f3cbe771129fe67d10e9d15/handlers.go#L865-L874

You need to manually add the code to set the thumbnail preview from here - https://github.com/tulir/whatsmeow/issues/204#issuecomment-1188619306

Also, to properly see the effect of not setting thumbnails, you need to turn off media auto-download from WhatsApp Chat settings.

All images/videos sent from wuzapi will now appear blurry or blank until manually downloaded.

hernanbozzano commented 2 weeks ago

It's not the platform, it's because wuzapi doesn't have code to set thumbnail preview here -

https://github.com/asternic/wuzapi/blob/99879886604546de9f3cbe771129fe67d10e9d15/handlers.go#L865-L874

You need to manually add the code to set the thumbnail preview from here - tulir/whatsmeow#204 (comment)

Also, to properly see the effect of not setting thumbnails, you need to turn off media auto-download from WhatsApp Chat settings.

All images/videos sent from wuzapi will now appear blurry or blank until manually downloaded.

thank you for your explanation. unfortunately, this is way above my understanding and my knowledge, i will end up using without the blurry effect..

i was using another github repo https://github.com/HunterXProgrammer/Tasker-mdtest-v4 but unfortunately -until now- it is not under mantaince by the developer