C# Issues With Special Characters

64 views
Skip to first unread message

MiloCaruso

unread,
Jul 28, 2010, 9:42:58 AM7/28/10
to Twitter Development Talk
I have searched and searched and not found a good solution to being
able to send special characters in status updates using c#. I can send
status updates that contain most ASCII characters (but not all).

fore example, this would work:

I love twitter

but this will fail:

twitter = love

I am using oAuth and the error I get back is that I am
unauthenticated. This would indicate that my signature is not being
generated correctly. In the one that fails I know that it is the "="
that is causing the issue but can't seem to get around this. I get the
same when I use any kind of Unicode character as well.

Does anyone have any ideas or suggestions?

Thanx!

Milo

Cameron Kaiser

unread,
Jul 28, 2010, 11:00:52 AM7/28/10
to twitter-deve...@googlegroups.com

How are you encoding each of those tweets in your OAuth requests?

--
------------------------------------ personal: http://www.cameronkaiser.com/ --
Cameron Kaiser * Floodgap Systems * www.floodgap.com * cka...@floodgap.com
-- Madness takes its toll. Have exact change ready. ---------------------------

MiloCaruso

unread,
Jul 28, 2010, 1:02:01 PM7/28/10
to Twitter Development Talk
I am using a "built in" url encoding method that was included in the
oAuth library. I have seen it referenced many times and it is supposed
to work to url encode.
>   Cameron Kaiser * Floodgap Systems *www.floodgap.com* ckai...@floodgap.com

Taylor Singletary

unread,
Jul 28, 2010, 1:28:06 PM7/28/10
to twitter-deve...@googlegroups.com
Hi Milo,

Though the process of URL encoding for OAuth is usually handled well by URL encoding libraries, there are times when they don't do the right things as far as what OAuth is expecting. Things like encoding "~" characters when they are to remain unencoded, for example.

One thing you want to verify is that you are first URL escaping characters in POST and query strings correctly -- according to the HTTP spec, rather than the OAuth spec. Any character that needs URL escaping/% encoding in a POST body needs to be encoded correctly before you even get to the OAuth part of calculations. OAuth then prescribes that certain characters be % encoded -- if your POST body already includes %-encoded characters, this usually means that for the OAuth signature base string they need to encoded again.

I have an example on github of nearly every possible UTF-8 character and how it should be represented at different stages of the request here: http://github.com/episod/oauth-utf8-character-map

Taylor

Cameron Kaiser

unread,
Jul 28, 2010, 1:29:03 PM7/28/10
to twitter-deve...@googlegroups.com
> I am using a "built in" url encoding method that was included in the
> oAuth library. I have seen it referenced many times and it is supposed
> to work to url encode.

Can you post relevant portions of your code and the output?

--
------------------------------------ personal: http://www.cameronkaiser.com/ --
Cameron Kaiser * Floodgap Systems * www.floodgap.com * cka...@floodgap.com

-- Line printer paper is strongest at its perforations. -----------------------

MiloCaruso

unread,
Jul 29, 2010, 2:19:37 PM7/29/10
to Twitter Development Talk
We meet again online and thank you Taylor!

On Jul 28, 1:28 pm, Taylor Singletary <taylorsinglet...@twitter.com>
wrote:
> Hi Milo,
>
> Though the process of URL encoding for OAuth is usually handled well by URL
> encoding libraries, there are times when they don't do the right things as
> far as what OAuth is expecting. Things like encoding "~" characters when
> they are to remain unencoded, for example.
>
> One thing you want to verify is that you are first URL escaping characters
> in POST and query strings correctly -- according to the HTTP spec, rather
> than the OAuth spec. Any character that needs URL escaping/% encoding in a
> POST body needs to be encoded correctly before you even get to the OAuth
> part of calculations. OAuth then prescribes that certain characters be %
> encoded -- if your POST body already includes %-encoded characters, this
> usually means that for the OAuth signature base string they need to encoded
> again.
>
> I have an example on github of nearly every possible UTF-8 character and how
> it should be represented at different stages of the request here:http://github.com/episod/oauth-utf8-character-map
>
Reply all
Reply to author
Forward
0 new messages