2013-02-26 154 views
0

有誰知道如果twitter分享按鈕的文本中不允許有問號嗎?我有以下代碼,當我點擊共享並彈出按鈕時,消息停在「誰是你最喜歡的候選人」。它不會讀取通過問號的文本。twitter分享按鈕中的問號

<?php 
$text = "Who's your favorite candidate ? This is another message";?> 
<a href="https://twitter.com/share?text=<?php echo $text; ?>&url=<?php echo $decoded_url; ?>&hashtags=contesthashtag" class="twitter-share-button" data-lang="<?php echo $lang; ?>" data-hashtags="contesthashtag" data-url="<?php echo $fanpage_url; ?>" data-text="<?php echo $text; ?>">Click here to share on Twitter</a> 

THANKs alot!

+1

你不需要在添加到鏈接之前對'$ text'進行URL編碼嗎?所以,試試像'<?php echo urlencode($ text); ?>' – 2013-02-26 21:46:56

回答

1

您需要在將文本作爲鏈接放置之前對其進行urlencode編碼。

<?php 
$text = urlencode("Who's your favorite candidate ? This is another message"); 
?> 

然後通過twitter共享按鈕鏈接傳遞$ text變量。