One issue with your implementation is that you are not using Twitter API
URLs.

Twitter API URLs have api.twitter.com as the domain and /1/ as the version
before any resource.

http://api.twitter.com/1/statuses/home_timeline.xml
http://api.twitter.com/1/statuses/update.xml

If you don't use those style URLs, you are going to run into many issues.

Next: using OAuth on the query string leads to more problems than it is
worth. If you use HTTP headers instead, you separate concerns between the
resource you're trying to access and the credentials you're using to access
them. It makes it much easier for others to assist you as well.

Your oauth_token value should only be changing between requests if you're
representing a different user. If it's changing and you don't know why, it's
time to get intimate with your code path & your library's code path.

Finally, are you sure that your application is setup as a read/write
application? If it's set as a read-only app, and you want to POST a status
update, you'll need to change it to a r/w application, expire the access
token manually at http://twitter.com/settings/connections and then re-issue
the access token.

Taylor

On Fri, Oct 1, 2010 at 7:51 AM, eMailaya <a...@emailaya.com> wrote:

> the error is:
> http/1.1 401 unauthorized
>
> trying again (3rd time) to call the 2 calls again i succeed with
> getting the user's statuses but not his followees
> the fact that the oauth_token=X was different between the 2 first and
> last calls, is it ok?
> (each button press makes 2 calls sequentially, one for the user's
> statuses and the other for the followees, also i tried to wait 5
> seconds between the calls but it didnt help)
>
> thanks!
>
>
> On Oct 1, 12:56 pm, Thai Pangsakulyanont <org.yi.dt...@gmail.com>
> wrote:
> > Everything looks normal to me, so I have no idea why it didn't work.
> >
> > When it said Unauthorized, did the API say anything else about it?
> > Like incorrect signature, or something like that.
> >
> > On Oct 1, 5:05 pm, eMailaya <a...@emailaya.com> wrote:
> >
> > > * please read my comments inside the <>
> > > * i store the token and token secret and i checked and they are the
> > > same
> >
> > > here is what i do step by step until it doesnt work. first i ask for
> > > authorization and get it with a PIN. then the user enters the PIN and
> > > gets the information.
> > > first i call for the user's statuses and this works:
> http://twitter.com/statuses/user_timeline/
> <user>.xml?oauth_consumer_key=<consumer
> > >
> key>&oauth_nonce=F89B4E724909C57D71193B24D075B88F&oauth_signature_method=HMAC-
> > > SHA1&oauth_signature=<oauth sig, changes every
> > > call>&oauth_timestamp=1285925817&oauth_token=<oauth token, same as in
> > > the next call, different than the other 2 calls>&oauth_version=1.0
> >
> > > then i ask for the followees statuses and that is working too:
> http://twitter.com/statuses/friends_timeline.xml?count=10&oauth_consu..
> .<consumer
> > >
> key>&oauth_nonce=8C822206BE598A78CF97E942CB8A24E5&oauth_signature_method=HMAC-
> > > SHA1&oauth_signature=<oauth sig, changes every
> > > call>&oauth_timestamp=1285925833&oauth_token=<same as previous call,
> > > different than the next 2 calls>&oauth_version=1.0
> >
> > > then i simply press the button again to make the same 2 calls once
> > > again, first i ask for the user statuses and this works:
> http://twitter.com/statuses/user_timeline/emailaya.xml?oauth_consumer..
> .<consumer
> > >
> key>&oauth_nonce=F7414A51B2D59AF04E13D7D2A58821DA&oauth_signature_method=HMAC-
> > > SHA1&oauth_signature=<oauth sig, changes every
> > > call>&oauth_timestamp=1285925869&oauth_token=<oauth token, different
> > > than the ones from above, same as in the next call>&oauth_version=1.0
> >
> > > then i ask for the followees statuses but this time, it doesnt work
> > > with the not authorized error:
> http://twitter.com/statuses/friends_timeline.xml?count=10&oauth_consu..
> .<consumer
> > >
> key>&oauth_nonce=3AC90E2A7C528953FC32A1B909D54B53&oauth_signature_method=HMAC-
> > > SHA1&oauth_signature=<oauth sig, changes every
> > > call>&oauth_timestamp=1285925897&oauth_token=<same as in the above
> > > call>&oauth_version=1.0
> >
> > > what am i missing?
> > > the weird thing is that the user statuses do work but the right after
> > > that i call the followees statuses and that doesnt work, though just 2
> > > seconds ago, in the previous 2 calls, right after the authorization,
> > > it did work with no problem.
> >
> > > to update a status, right after the authorization from the user, i
> > > call to this url:http://twitter.com/statuses/update.xmlbutagain, i
> > > get unauthorized. i never succeeded to update a status for that
> > > reason. here there is no complex url that contains parameters
> > > what am i missing?
> >
> > > On Oct 1, 7:09 am, Thai Pangsakulyanont <org.yi.dt...@gmail.com>
> > > wrote:
> >
> > > > You have to make sure that `Twitterh.OAuth_token` and
> > > > `Twitterh.OAuth_token_secret` stays same before and after restarting
> > > > the application. Also, make sure that `oauth_timestamp` is up to date
> > > > and `oauth_nonce` is unique each time you make a request.
> >
> > > > On Oct 1, 6:05 am, eMailaya <a...@emailaya.com> wrote:
> >
> > > > > i could really use some help here
> > > > > thanks
> >
> > > > > On Sep 29, 7:05 pm, eMailaya <a...@emailaya.com> wrote:
> >
> > > > > > any kind of help here will be appreciated
> > > > > > thanks
> >
> > > > > > On Sep 28, 8:06 pm, eMailaya <a...@emailaya.com> wrote:
> >
> > > > > > > im doing the following:
> >
> > > > > > >     Twitterh.Key := <consumer key - hard coded>
> > > > > > >     Twitterh.Secret := <consumer secret - hard coded>
> > > > > > >     Twitterh.OAuth_token :=
> > > > > > > SettingsFile.ReadString('TWITTER','TOKEN',''); //saved from
> when i got
> > > > > > > the authorization from the user
> > > > > > >     Twitterh.OAuth_token_secret :=
> > > > > > > SettingsFile.ReadString('TWITTER','TOKENSECRET',''); //saved
> from when
> > > > > > > i got the authorization from the user
> >
> > > > > > > after getting the authorization from the user i can do both
> getting
> > > > > > > the statuses of the user and the followees but NOT updating the
> > > > > > > status.
> > > > > > > after "restart" of the application, at first try i do succeed
> to
> > > > > > > receive the user's statuses but not his followees' , on second
> try
> > > > > > > (without restart), i can do nothing and all for the same
> reason: not
> > > > > > > authorized
> >
> > > > > > > not sure i understood the other reply of re-hashing, hashing of
> what
> > > > > > > exactly? the only place i do some "processing" is when i ask
> for
> > > > > > > authorization from the user. i want it so once i have it, to
> not need
> > > > > > > to re-ask it over and over again
> >
> > > > > > > what am i missing?
> > > > > > > thanks
> >
> > > > > > > On Sep 28, 10:52 am, Tom van der Woerdt <i...@tvdw.eu> wrote:
> >
> > > > > > > > If you save those four keys, you should have everything you
> need to
> > > > > > > > restore the "session".
> >
> > > > > > > > If this does not work for you, make sure that you save the
> keys
> > > > > > > > properly. For example, you don't want to confuse oauth_token
> with
> > > > > > > > oauth_consumer_key.
> >
> > > > > > > > Tom
> >
> > > > > > > > On 9/28/10 12:39 AM, eMailaya wrote:
> >
> > > > > > > > > Im developing a desktop application. firstly, the user
> needs to
> > > > > > > > > approve my app to let it access his account, enter the PIN
> code and
> > > > > > > > > retrieve his statuses and his followees' statuses, all is
> working
> > > > > > > > > fine.
> >
> > > > > > > > > im closing my application and re-open it. now i already
> have his PIN
> > > > > > > > > code so im skipping the authorization part. i put the
> oauth_key and
> > > > > > > > > oauth_key_secret, the consumer_key and consumer_secret and
> ask for his
> > > > > > > > > statuses, this one works but when i want to retrieve his
> followees
> > > > > > > > > statuses i get "unauthorized" error. trying again causing
> the
> > > > > > > > > "unauthorized" error also for his statuses. the only way to
> solve this
> > > > > > > > > problem is to ask for an authorization everytime, this is
> annoying.
> >
> > > > > > > > > also, i cant update the status for the same reason/error
> > > > > > > > > any idea what am i missing?
> > > > > > > > > thanks
>
> --
> 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