Usually the community tends to close this type of question (related to Whatsapp), erroneously in my opinion.
Related questions usually do not understand the function-related API "share" Whatsapp and its peculiarities, which are nothing different from other great services like Facebook, Twitter, etc... which I make available a "endpoint" for the user to share content and external information on the network.
Two perspectives should be observed here:
- if the user is accessing from a mobile device
- if the user is accessing from a desktop
The "endpoint" Whatsapp accepts only two parameters: phone and text and both should have the content encoded, in your case using PHP would be something like
<?php echo urlencode(get_permalink()); ?>
It should be noted that the field phone should be in international format (country code + area code + phone number) only in numbers, example:
// Brasil DDD (RS) número (omitido por X)
5551XXXXXXXXX
Depending on the perspective (mobile or desktop) endpoind mute.
For a navigation mobile should be using the protocol whatsapp://send?
which 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 an application to open this type of protocol.
Already in navigation desktop the link is used https://api.whatsapp.com/send?
which will go to the domain of the Whatsapp web application (PWA), if the user has not used this application previously (not logged in) he will be informed of the same.
This function does not automatically send, it opens a user confirmation window. If it confirms then opens the dialog where the user should then click the send button.
If the meter phone if deleted the application Whatsapp (desktop or mobile) will open a modal for the user to choose for who wants to send the content, contact list or even their groups.
I don’t think it’s duplicate but surely your question can be related to another one here in the community to which I’ve already answered: Send a message to Whatsapp via site [closed]
It is worth taking a look at this since, the "magic" to trace a more correct approach happens in the frontend
(javascript).
This is my demo already published in the aforementioned question as related: DEMO
Source: https://faq.whatsapp.com/en/android/26000030/? Category=5245251
Oxi, the hater on duty could enrich the question by presenting a "better" answer or commenting to "we can" know what to improve the answer given... downvote because you didn’t understand the question (or the answer) must be too much bitterness in the heart. I just think.
– Lauro Moraes
There’s always a few suckers... great answer!
– Maurício Júnior