Link "Share on Whatsapp"

Asked

Viewed 2,601 times

4

Based on this code

        <li><a class="whatsapp" title="<?php esc_html_e( 'Compartilhar no WhatsApp', 'grandmagazine' ); ?>" target="_blank" href="whatsapp://send?text=<?php the_permalink() ?>&url=<?php echo get_permalink(); ?>"><i class="fa fa-whatsapp"></i></a></li>

Where am I wrong that doesn’t work on my share page?

Appears like this

Whatsapp://send? text=http://tucnews.com.br/bica-comorunninga-mais-popular-fonte-de-agua-de-tucurui-2/&url=http://tucnews.com.br/bica-comorunninga-popular-fonte-de-agua-de-tucurui-2/

In the browser, but the page is empty.

This is a code that works for Facebook

    <li><a class="facebook" title="<?php esc_html_e( 'Compartilhar no Facebook', 'grandmagazine' ); ?>" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink(); ?>"><i class="fa fa-facebook"></i></a></li>

Where is the error?

2 answers

7

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.

  • There’s always a few suckers... great answer!

2

Friend, your mistake, and because this link will only work on mobile.. or will only open if you are accessing this link with a mobile, with Whatsapp installed to be able to work.

I hope I’ve helped.

  • If you do not have Whastapp installed on mobile, will be blank page also.

  • If you have Whatsapp Web enabled on your desktop it will work too.

  • On the contrary. It works on the desktop, but when I share by mobile redirects to the browser of the mobile asking to install Whatsapp.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.