Usually the community tends to close this type of question (related to WhatsApp), erroneously in my opinion.
Related questions usually do not understand the API related to WhatsAPP's "share" function and its peculiarities, which are nothing different from other great services like Facebook, Twitter, etc ... that provide an endpoint for the user to share content and external information on the network.
Two perspectives should be noted here:
- if the user is accessing from a mobile device
- if the user is accessing from a desktop
WhatsApp endpoint accepts only two parameters: phone and text and both must have the content encoded, in your case using PHP would be something like
<?php echo urlencode(get_permalink()); ?>
It should be noted that the phone field should be in international format (country code + area code + phone number)
// Brasil DDD (RS) número (omitido por X)
5551XXXXXXXXX
Depending on the perspective (mobile or desktop) endpoind changes.
For a mobile navigation you should use the whatsapp://send?
protocol that will open the application if it is installed on the user's device, otherwise it will open the system interface for the user to choose a application to open this type of protocol.
In desktop navigation you use the https://api.whatsapp.com/send?
link that will go to the WhatsApp web application domain (PWA), if you have not previously used this application (not logged in) he will be informed of it.
This function does not send automatically, it opens a window for user confirmation. If it confirms then it opens the dialog where the user should then click the submit button.
If the phone parameter is suppressed, the WhatsApp application (desktop or mobile) will open a modal for the user to choose from for sending content, contact lists or even groups.
>
I do not think it's duplicate but surely your question may be related to another one here in the community to which I've already replied: Send a message to WhatsApp via site [closed]
It's worth taking a look at this once, the "magic" to draw a more correct approach happens in frontend
(javascript).
This is my demo already published in the above question as related: DEMO
Source: link