Benjamin
Benjamin

Reputation: 31

How can I post to my WhatsApp status using JavaScript?

I'm looking for a way to programmatically post things to my WhatsApp status using JavaScript. I want to automate the process and make it easier to share updates with my contacts. Are there any APIs or npm packages available that can help me achieve this?

I've searched online, but I haven't found a straightforward solution. It would be great if someone could point me in the right direction or provide some guidance on how to accomplish this task. Thanks in advance for any help or suggestions!

i found a chrome extension that does that but i can’t inspect it to understand how it was achieved and i have searched the internet.

Upvotes: 3

Views: 565

Answers (1)

Hafiz
Hafiz

Reputation: 256

It is possible to post statuses programmatically. I use a service gateway for this. They have a sandbox for testing and working. You can place statuses of different types, both pictures and just text with a colored background. A mandatory parameter should be an array of numbers to which the status will be displayed (including your own)

const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    authorization: 'Bearer Your_Token'
  },
  body: JSON.stringify({
    background_color: '#00000000',
    caption_color: '#FFFFFFFF',
    caption: 'Hello world',
    font_type: 'SANS_SERIF',
    // media: 'data:image/png;name=test.png;base64,iVBORw0KG...........',
    contacts: ['any number', 'any number']
  })
};

fetch('https://gate.whapi.cloud/stories', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Read more about the method here: https://whapi.readme.io/reference/createstory

You will need a token from provider. Attention, this is an unofficial solution, so use at your own risk.

Upvotes: 0

Related Questions