A bunch of plus signs in tweets via web intents

webintent
php

#1

I am using the Tweet Web Intent to generate simple “tweet this” buttons. My PHP code looks something like this:

echo https://twitter.com/intent/tweet?text='.urlencode($my_text);

In a few tweets, the plus signs do not get stripped out. In most tweets they do get stripped out. Check this search result (view the “Live” tab). There’s a bunch of correct ones and a bunch of wrong ones, but the wrong ones are in the minority.

They all originate from this page on my site.

Can I do something about this? Or does the fault lie with Twitter?


#2

Use rawurlencode instead for RFC 3986 encoding.


#3

Thanks! That seems to do the trick. Can you share any insight into why the urlencoding with pluses works most of the time, but fails sometimes?


#4