Think of it this way.. a valid POST body already must contain
application/x-www-form-urlencoded encoded values for the body to be valid.
Normalizing spaces to %20, and avoiding "+" is also a best practice. OAuth
kicks in after you've already constructed a valid POST body.

Here's an example of tracking a term with a space character in it: "twitter
api"

== POST Body
track=twitter%20api

== signature_base_string
POST&http%3A%2F%2Fstream.twitter.com
%2F1%2Fstatuses%2Ffilter.json&oauth_consumer_key%3Dri8JxYK2ddwSV5xIUfNNvQ%26oauth_nonce%3DQKWqIP8eEedgOPk5ujopscNxqeoafDNC0r6TZyLFM%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1289400791%26oauth_token%3D819797-torCkTs0XK7H2Y2i1ee5iofqkMC4p7aayeEXRTmlw%26oauth_version%3D1.0%26track%3Dtwitter%2520api

== Authorization Header
Authorization: OAuth
oauth_nonce="QKWqIP8eEedgOPk5ujopscNxqeoafDNC0r6TZyLFM",
oauth_signature_method="HMAC-SHA1", oauth_timestamp="1289400791",
oauth_consumer_key="ri8JxYK2ddwSV5xIUfNNvQ",
oauth_token="819797-torCkTs0XK7H2Y2i1ee5iofqkMC4p7aayeEXRTmlw",
oauth_signature="jaEvelmcrQOkHdWADBvwZsQeGiQ%3D", oauth_version="1.0"

Taylor


On Wed, Nov 10, 2010 at 1:38 AM, Ciaran <ciar...@gmail.com> wrote:

> Try ui-encoding them first, my understanding of the Twitter OAuth
> signature validation is that it is non-standard (although there
> appears to be debate about this) I suspect if you encode them first
> before signing the url it will start to work
> -cj.
>
>
> On Tue, Nov 9, 2010 at 6:11 PM, dan <dfran...@gmail.com> wrote:
> > I've been having trouble connecting to the streaming API using oauth
> > if my tracks have spaces. I get 401s (unauthorized). In all cases, the
> > same code works if the tracks don't have spaces.
> >
> > In Java: tried twitter4j (http://twitter4j.org/jira/browse/TFJ-420)
> > and tweetstream4j (http://stackoverflow.com/questions/4129622/
> > connecting-to-twitter-streaming-api-with-tracks-with-spaces-using-
> > apache-httpclie)
> >
> > In Python: tried tweepy (https://github.com/joshthecoder/tweepy/
> > issues#issue/64)
> >
> > The Twitter example using curl (http://dev.twitter.com/pages/
> > streaming_api_methods#track) works with tracks that have spaces, but
> > it's basic auth.
> >
> > I am wondering if some oauth encoding versus POST param encoding is
> > not working out.
> >
> > Can someone point me to a code example in Java or Python that is known
> > to work connecting to the Twitter streaming API using oauth that has
> > spaces in its tracks?
> >
> > Thanks in advance.
> >
> > --
> > Twitter developer documentation and resources:
> http://dev.twitter.com/doc
> > API updates via Twitter: http://twitter.com/twitterapi
> > Issues/Enhancements Tracker:
> http://code.google.com/p/twitter-api/issues/list
> > Change your membership to this group:
> http://groups.google.com/group/twitter-development-talk
> >
>
> --
> Twitter developer documentation and resources: http://dev.twitter.com/doc
> API updates via Twitter: http://twitter.com/twitterapi
> Issues/Enhancements Tracker:
> http://code.google.com/p/twitter-api/issues/list
> Change your membership to this group:
> http://groups.google.com/group/twitter-development-talk
>

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to