无法在whatsapp中分享包含url参数的链接


Not able to share the link in whatsapp which contains parameters in url

我有一个链接,需要在whatsapp中共享,看起来像下面所示的。

<?php 
$temp = 'whatsapp://send?text=http://www.example.com/index.php?
           secid=1&url=/content/575098/ready-opposed.html';
?>
<a href="<?php echo urlencode($temp); ?>">
  <img src="img_uploads/watsapp.png" width="18" height="18"/>
</a>  

所以现在当我通过移动网站分享它时,在Whatsapp中我只得到http://www.example.com/index.php?secid=1,但下一个参数url不在那里。只是为了测试我是否把url作为第一个参数,把secid作为第二个参数,然后我只收到url,而不是secid。

在我的场景中,只有当这两个参数存在时,页面才会呈现

有人能帮我解决这个问题吗

使用rawurlencode()代替urlencode()例如

<?php
$value = 2;
$text = rawurlencode("www.domain.com/products.php?Id=".$value);
?>
<a href="https://api.whatsapp.com/send?text=<?php echo $text; ?>"><i class="fa fa-whatsapp"></i></a>

我正在恢复一个旧的/死的答案,但我有同样的问题,并解决了特殊字符的URLencoding。

在本例中,convert the & with %26

一些参考:

  • https://www.w3schools.com/tags/ref_urlencode.asp
  • http://php.net/manual/en/function.urlencode.php

我解决了一个类似的问题:

$value = 2;
$message_to_send = urlencode(rawurlencode("www.domain.com/products.php?Id=".$value))