Problem with codification of character "~"


We have a problem when making a Status Update. What happens is that we are making the character encoding with Percent encode extended UTF-8 and then send the request to the API without having problems with most of the characters. However, when making the character encoding for “~” in the following way %7E we received the following reply “Could not authenticate with OAuth”, therefore we wanted to consult you how we should make the character encoding for that character (~) in order to avoid problems with authentication with OAuth.


Problems with the tilde character are not uncommon – different versions of percent encoding implementations behave differently with this sometimes reserved character. For Twitter, it’s recommended to just not encode it at all. Theoretically, it should work fine if you do encode it in a POST body, as long as in the OAuth signature base string it is double encoded (as any already percent-encoded value should be).

Here’s an example of posting a status update with a tilde character successfully…

Posting the status: “Aunt Ma~”

My POST body becomes: status=Aunt%20Ma~

My signature basestring: