Question

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.

<?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!

Was it helpful?

Solution

You need to urlencode the text before placing it as a link.

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

Then pass that $text variable through the twitter share button link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top