Share links by facebook or whatsapp with GET variables without losing or modifying

0

How to share the current linen (with its get parameters) with the whatsapp app making me recognize all the variables.

This is what happens: I can not share more than one variable with whatsapp because it adds these special characters:

  

link

and it adds everything that is after HELLO, this causes that they do not load all the variables correctly leaving echos empties.

Code:

<?php

function url_completa($forwarded_host = false) {

$ssl   = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';

$proto = strtolower($_SERVER['SERVER_PROTOCOL']);

$proto = substr($proto, 0, strpos($proto, '/')) . ($ssl ? 's' : '' );

if ($forwarded_host && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {

$host = $_SERVER['HTTP_X_FORWARDED_HOST'];

} else {

if (isset($_SERVER['HTTP_HOST'])) {

$host = $_SERVER['HTTP_HOST'];

} else {

$port = $_SERVER['SERVER_PORT'];

$port = ((!$ssl && $port=='80') || ($ssl && $port=='443' )) ? '' : ':' . $port;

$host = $_SERVER['SERVER_NAME'] . $port;

}

}

$request = $_SERVER['REQUEST_URI'];

return $proto . '://' . $host . $request;

}

$url = url_completa();

$urlnewp= htmlspecialchars($url);

$urlwp= urlencode ( $urlnewp );

?>





<?php echo '<a class="icon-whatsapp" href="https://api.whatsapp.com/send?text='.$urlwp.'"></a>';  ?>

Something similar happens with Facebook but there I add these characters: link when the correct one should be: link

    
asked by Gatoles v 22.12.2018 в 10:25
source

0 answers