Reputation: 57
I am fetching current URL which is having 1 dynamic id. When I am trying to print the fetched URL than its proper. But when I am going to share it on WhatsApp via WhatsApp API link then dynamic id from the URL is not fetching.
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo "<a href='https://api.whatsapp.com/send?text=$actual_link' data-action='share/whatsapp/share'>Whatsapp</a>"; ?>
Structure MVC
Upvotes: 0
Views: 1253
Reputation: 2536
The reason it's probably not working is because you are putting a URL in a URL. Try to urlencode
your link variable first:
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo "<a href='https://api.whatsapp.com/send?text=" . urlencode($actual_link) . "' data-action='share/whatsapp/share'>Whatsapp</a>"; ?>
Upvotes: 1