joaomirandas / whats2api

🎉 This library provide you an complete solution for WhatsApp REST API
https://www.npmjs.com/package/w2api-master
MIT License
181 stars 72 forks source link

How to run w2api in AWS EC2 Ubuntu 18 #7

Closed lemessenoire closed 4 years ago

lemessenoire commented 4 years ago

Greetings, this is the way to configure w2api on Ubuntu 18.0 on AWS EC2

You must first install the necessary dependencies:

sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget xvfb

Clone the w2api repository to the directory you want

git clone https://github.com/joaomirandasa/w2api

run npm install

To finish, type this command in terminal:

xvfb-run node debug.js

lemessenoire commented 4 years ago

I have found an even simpler solution to be able to make w2api work in Ubuntu, it is very simple.

Go to the file located on this path:

w2api/modules/whatsapp.js

Then go to line 194 and change the parameter headless: false to headless: true and voila, it works perfectly just typing node debug.js

I hope this is helpful to you. 20200407_161207

joaomirandas commented 4 years ago

Sorry! My bad!

Let me explain better, This code runs WhatsApp Web in a browser on the host machine, that is, the code is nothing more than countless action instructions within WhatsApp Web - so you can initialize this code by having the browser graphical view running or not and this is controllable by the headless parameter that you noticed.

If you need to understand what is happening with the execution of your code running locally you can set the headless to false and therefore when you initialize the code, you will notice that a Chrome browser is open and all the automation sent via REST is performed inside, however if you are going to run this in the cloud, you need to change the headless parameter to ftrue and therefore your code will be executed without the graphical browser interface.

By my mistake, I left the parameter as false and PUSH the version, it should be true from the beginning.