简体   繁体   中英

Chrome Extension Development using the Whatsapp API

I am trying to make a chrome extension that uses the WhatsApp API to share the link of the page I am at with just a click on the extension. The API is - https://wa.me/?text=urlencodedtext , where I provide the urlencodedtext.

the code I have written to perform this is - ( function(){ const YOUR_PHONE=''; window.open( https://api.whatsapp.com/send?phone=${YOUR_PHONE}&text=${encodeURIComponent(location.href)} ); } )();

The above code redirects me to the Whatsapp page. ScreenShot Being directed to the Whatsapp page make the process longer. Is there a way I can skip the Whatsapp page and go directly to the web whatsapp (or the desktop whatsapp).

I do not believe there is currently anyway to do this using that URL.

On Web, when you visit : https://api.whatsapp.com/send?phone=xxxxx&text=yyyy It will show an intermediate page with a "Send" button which would send via WhatsApp Web if you already have it configured.

However On Mobile, when you visit the same URL, it should load your WhatsApp App with the content , ready for you to press send.

For the extension you are trying to write, you would have to do the following:

  1. Receive the inputs from the Extension User.
  2. Check if WhatsApp Web is opened on any tab (meaning you need to have permission to view all open browser tabs) or Open a New Tab with WhatApp Web.
  3. Use Javascript to initiate a new message with the number you want (meaning you need permission to edit browser pages)

I don't believe you can use the WhatsApp URL (it is not the API) you mentioned to achieve your purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM