views:

126

answers:

1

For background information, I'm using TweetSharp 1.0 to do my tweeting. Callback urls are being recieved regardless of whether they contain a querystring parameter (CallbackConfirmed is true) but they don't redirect upon authorization when they have contain a querystring parameter. They head off to twitter looking fine and dandy (example: http://api.twitter.com/oauth/authorize?oauth_token=MYTOKENREMOVED&oauth_callback=http://www.mywebsite.co.uk?q=Woop%20Woop) but when twitter is supposed to redirect to the callback url, it just redirects them to twitter.com.

This appears to only happen when I use spaces in the callback url - oauth_callback=http://www.mywebsite.co.uk?q=Woop_Woop works whereas oauth_callback=http://www.mywebsite.co.uk?q=Woop%20Woop does not.

+1  A: 

Any querystring parameters you supply must be url encoded. Spaces should become "+" and not %20 (Server.UrlEncode will do the job in .NET). %20 is not the same as + so oauth_callback=http://www.mywebsite.co.uk?q=Woop%20Woop should become: oauth_callback=http://www.mywebsite.co.uk?q=Woop+Woop

In addition ... Server.UrlEncode will not quite work because "Hexadecimal characters in encodings MUST be upper case" (see section 5.1 of http://oauth.net/core/1.0/) and C# encodes to lowercase. I believe JavaScript also encodes to lower rather than uppercase. For C# a quick solution to the lowercase encoding problem can be found at: http://stackoverflow.com/questions/918019/net-urlencode-lowercase-problem

Mr Grok