Dan
Dan

Reputation: 3358

Can't share URL on twitter with a query string

I'm trying to tweet a URL with a query string and it's not working correctly. The URL is formed like this: http://example.com/videos/watch?v=123

My code is below

<a class="tw" href="https://twitter.com/intent/tweet?status=<?= urlencode($video[0]['tweet_text']) . 'http://example.com/videos/watch?v=' $video[0]['_pw']['id'] ?>">Tweet</a>

When I remove the number after v=, the tweet dialog shows up. When I keep the ?v=123, the tweet dialog just loads twitter.com.

Upvotes: 0

Views: 772

Answers (1)

JackPoint
JackPoint

Reputation: 4111

Try to encode the text and the url

<a class="tw" href="https://twitter.com/intent/tweet?status=<?= urlencode($video[0]['tweet_text'] . 'http://domain.com/videos/watch?v=' $video[0]['_pw']['id']) ?>">Tweet</a>

Upvotes: 3

Related Questions