mrahmat
mrahmat

Reputation: 617

php whatsapp sharing not sending entire link

I'm trying to share the entire link via whatsapp. Suppose I have the link on my browser as:

http://www.foo.com/foo?a=1&b=2

My normal way to share this link that I used is:

$actual_link="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";     
echo "<li><a href='whatsapp://send?text=$actual_link'>Share</a></li>"; 

When I hover my mouse over the anchor element, it shows the link correctly, but when I click on it and get into whatsapp, the message appears as:

http://www.foo.com/foo?a=1

Why am I not getting the second variable?

Upvotes: 4

Views: 1398

Answers (1)

Chris
Chris

Reputation: 4728

I have tested this myself on my Mac with the WhatsApp desktop application and the URL is passed correctly to WhatsApp:

<?php

$actual_link = urlencode("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);

echo "<li><a href='whatsapp://send?text=$actual_link'>Share</a></li>"; 

?>

So, if I go to to the URL below and click the share link then this is exactly what I see in WhatsApp

http://localhost/whatsapp.php?a=1&b=2

Upvotes: 1

Related Questions