whatsapp-api-tutorial icon indicating copy to clipboard operation
whatsapp-api-tutorial copied to clipboard

Trying to send an attachment

Open jhernancanom opened this issue 1 year ago • 8 comments

Hello. I have got to send an WhatsApp text message. I am trying to send an attachment.

I receive

OLE IDispatch exception code 0 from msxml6.dll: No se pudo establecer conexión con el servidor..

image

ejemplo-2-Send-Media-whatsapp-api-tutorial-master.zip

jhernancanom avatar Jul 06 '22 04:07 jhernancanom

You can follow the tutorial about sending media message.

ngekoding avatar Jul 06 '22 06:07 ngekoding

I am going to read it. Thanks.

El mié, 6 jul 2022 a la(s) 01:28, Nur Muhammad escribió:

You can follow the tutorial about sending media message.

—Message ID: @.*** .com>

jhernancanom avatar Jul 06 '22 06:07 jhernancanom

I tried to follow the instructions that I can see in the third video "Whatsapp API Tutorial: Sending Media File"

I am sending an image from the C: disk --file--, not from an URL --fileURL--.

I see that some changes shown in the video are not in the app.js that I got from the downloadable. I try to put the commands for sending a file, not a fileURL (I am attaching the first image --called editing-app-js-- that shows that).

And in the second image (called image-err-send-media) I show the err I am receiving: No se pudo establecer conexión con el servidor Cannot connect to server.

I confirm you that I could send several messages (without images) before trying to send media. But now --when I try to send a message without image-- I am receiving the same err.

I also confirm that I have updated the downloadable today because two days ago it were updated in GitHub.

The only changes were the shown in first image on app.js (I attach it)

When I made some tracing, I saw that it is related to isRegisteredUser. I attach a third image of the console.

image

image

image

image

app-js.zip

jhernancanom avatar Jul 10 '22 10:07 jhernancanom

image

jhernancanom avatar Jul 10 '22 11:07 jhernancanom

Any case of filename, it fails; and any slash it fails.

In the last four hours I got send two messages (without attachment) in different moments

Without attachment:

{ "number":"573007824844", "message":"Mensaje de prueba enviado con NgeKoding-WhatsApp-API-Tutorial" }.

With attachment: image

image

image

jhernancanom avatar Jul 10 '22 12:07 jhernancanom

After many (a lot-lot) tries today, I discovered:

  1. I can send messages without attached files, just text.
  2. If I try to send a simple image, the "node server" gets down (with the err shown in the next image) with a long-long JSON.
  3. After the node-server gets down, I have to install (¿from scratch?).
  4. After many-many tries I discovered that there must be a problem with hhtp://localhost:8000 for getting the QR, because I need to run NPM INSTALL and NPM RUN START:DEV, but sometimes the web explorer only shows CONNECTING and never get the QR and/or never gets AUTHENTICATED, and when I try to send via Postman or via my app I get an err as "Cannot connect to server" or "Server refuse the connection". I have wait for a long as seven minutes for node command line shows AUTHENTICATED and I could send a text message.
  5. I had not edited (changed) the content in APP.JS for sending media. You recomend me to see the video, then I decided to make some modifications.... for not using AXIOS nor FILEURL, but I received the same err.... sending a text-message AND also sending a media-message.... Then I prefer to get the original APP.JS... and the err I got is the same. My current APP.JS is what is the one contained in the downloadable (without modifications/adjustments, this is the right way, right? I consider I dont need to go to see the videos, because the downloadable has all the necessary to run --I suppose this--).
  6. In fourth video I see that FILEURL is used when an image to attach is in an URL, and I thougt that I would need to get FILEURL off and use CONST FILE = REQ.FILES.FILE, but --as I got the same err, several times-- I gave up and I consider that I can use FILEURL even when the attached is in local C: disk (just because I think the downloadable must have all whats is needed to run effectively).

image

jhernancanom avatar Jul 11 '22 03:07 jhernancanom

Can you please attach your code for sending the media message? And in postman how you attach the file?

ngekoding avatar Jul 12 '22 08:07 ngekoding

The current code handle for file from an URL, so you must fill the file field and give it value for the file URL. And here we use axios to download it, then create a MessageMedia.

https://github.com/ngekoding/whatsapp-api-tutorial/blob/ec18a0173623961363ac6cd97af0199474c2256b/app.js#L210-L223

ngekoding avatar Jul 12 '22 08:07 ngekoding