Question marks in the twitter share button


#1

Does anyone know if question marks arent allowed in the text for the twitter share button? I have the following code and when I click on the share and the popup button appears, the message stops at “Who’s your favorite Candidate”. It doesnt read the text past the question mark.

$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>

#2

Hi Vanessa,

We take the version of the text parameter from the URL over the version in the HTML attribute, which in this case you need to URL encode, else the ? characters will confuse the browser. e.g. https://twitter.com/share?text=<?php echo urlencode($text); ?>.

Ben


#3

Ben you just safed my day :slight_smile:


#4

#5