Problem with codification of character "~"


#1

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.
Regards.


#2

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:

POST&http%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.json&oauth_consumer_key%3Dri8JxYK2ddwSV5xIUfNNvQ%26oauth_nonce%3Df9Evb9Dt4Bm7Dvy30KTD0X39ZPOsUi7KWlnwXhxq8%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1274109819%26oauth_token%3D119476949-gF0B5O1Wwa2UqqIwopAhQtQVTzmfSIOSiHQS7Vf8%26oauth_version%3D1.0%26status%3DAunt%2520Ma~