createTwitterAccount (aka create tipjoy account via twitter) result incorrect?

1 view
Skip to first unread message

divesnob

unread,
Jun 5, 2009, 2:03:58 PM6/5/09
to Tipjoy Developers
I posted earlier in the week that I thought I was having issues w/ the
oauth headers. However, I think it's the return codes that are coming
back from tipjoy that might be the problem.

If I make a call to createTwitterAccount by passing in the screen_name
and the oauth header for an account that is already hooked up - I get
the following:

{"reason": "invalid twitter_oauth_header. id:1", "request": "/api/
createTwitterAccount/", "result": "failure"}

However, I know that the oauth headers work, because calling for a
balance on the same account is a success:

{"currency": "USD", "balance": 0.0, "request": "/api/user/balance/?
twitter_username=tobea_dev&twitter_oauth_header=OAuth
%20oauth_consumer_key%3D%243gferwfetMxxxyyyybaWi9H3Kw%22%2Coauth_token
%3D%224favq345v6FGaY01tX3FZsenC24py0EesZAVdqs%22%2Coauth_nonce%3D
%2235170cb749c386de3d2967135e9e2c76%22%2Coauth_timestamp%3D
%221244224652%22%2Coauth_signature_method%3D%22HMAC-
SHA1%22%2Coauth_version%3D%221.0%22%2Coauth_signature%3D
%22%252FTpubWDyW8MT9hFGXOJVXov9RhI%253D%22", "result": "success"}

If I remove twitter from the accont and try to call the
createTwitterAccount again I get the following:

{"reason": "no such tipjoy user", "request": "/api/
createTwitterAccount/", "result": "failure"}

Yet checking if the account exists returns success:

{"username": "tobea_dev3", "verified": false, "exists": true,
"user_id": 57520, "profile_image_url": "http://s3.amazonaws.com/
twitter_thumbs/default.jpg", "twitter_username": "tobea_dev",
"result": "success", "twitter_user_id": "44429407", "is_private":
false, "date_joined": "2009-06-05 10:57:15"}

Notice the incremented username - tobea_dev3.

I can do this over and over again and I get the same results. Is
there a bug with what we should be getting back as a result on
success?

-matt

divesnob

unread,
Jun 9, 2009, 12:33:24 PM6/9/09
to Tipjoy Developers
Has anyone been able to successfully use this API call with oauth?

Drew Perttula

unread,
Jun 9, 2009, 12:40:35 PM6/9/09
to tipjoy-d...@googlegroups.com
divesnob wrote:
> Has anyone been able to successfully use this API call with oauth?
>
> On Jun 5, 11:03 am, divesnob <m...@veodia.com> wrote:
>> I posted earlier in the week that I thought I was having issues w/ the
>> oauth headers. However, I think it's the return codes that are coming
>> back from tipjoy that might be the problem.
>>
>> If I make a call to createTwitterAccount by passing in the screen_name
>> and the oauth header for an account that is already hooked up - I get
>> the following:
>>
>> {"reason": "invalid twitter_oauth_header. id:1", "request": "/api/
>> createTwitterAccount/", "result": "failure"}
>>

Yes, this has been working for me. I'm using the python oauth library
you get with easy_install (there are others, which is confusing).

from restclient import RestClient

req = _signed_request(
consumer, token=accessToken,
http_method="GET",
http_url='http://twitter.com/account/verify_credentials.json',
)
oauthHeader = req.to_header()['Authorization']
ret = RestClient().post(
"http://tipjoy.com/api/createTwitterAccount/", path="",
body=urllib.urlencode(dict(
twitter_username=str(graph.value(user, TW.screen_name)),
twitter_oauth_header=oauthHeader)),
headers=uaHeader)
ret = jsonlib.loads(ret)
if ret['result'] != 'success':
raise ValueError(ret['reason'])


_signed_request is also mine:


from oauth.oauth import OAuthRequest, OAuthConsumer, OAuthToken
from oauth.oauth import OAuthSignatureMethod_HMAC_SHA1

def _signed_request(consumer, token=None, **oauth_request_kw):
"""
the other named args are
http_method='GET', http_url=None, parameters=None
"""
req = OAuthRequest.from_consumer_and_token(
consumer, token=token, **oauth_request_kw)
req.sign_request(OAuthSignatureMethod_HMAC_SHA1(), consumer, token)
return req


divesnob

unread,
Jun 10, 2009, 1:40:45 PM6/10/09
to Tipjoy Developers
Hey Drew...

Thanks for the update. Using a php lib on my end here, but I was
concerned about the responses I was getting back from tipjoy. You're
getting back the correctly documented responses I take it?

Thx..
-matt
Reply all
Reply to author
Forward
0 new messages