benhowdle89
benhowdle89

Reputation: 37504

Tweet share button missing off GET parameters

Any idea why when i click the Tweet button, it only takes the URL of http://www.humanisms.co.uk/single.php. And misses everything after this! Any ideas how i can get around this?

echo "<a href='http://twitter.com/share?url=http://www.humanisms.co.uk/single.php?id='".$row['id']."'&via=humanisms_uk&text=Humanisms' class='twitter-share-button'>Tweet</a>";

Upvotes: 0

Views: 720

Answers (1)

netcoder
netcoder

Reputation: 67745

Probably because you are using the query string delimiter ? twice, which is invalid. You have to url-encode it, along with &. In fact, you're better off encoding the whole thing:

$url = rawurlencode("http://www.humanisms.co.uk/single.php?id={$row['id']}&via=humanisms_uk&text=Humanisms");
echo "<a href='http://twitter.com/share?url=$url' class='twitter-share-button'>Tweet</a>";

I also noticed you had quotes around the id parameter, not sure if that was intentional or not.

Upvotes: 3

Related Questions