2010年1月23日 星期六

Python code to use OAuth get Jaiku actor info

import urllib2 from oauth import oauth consumer = oauth.OAuthConsumer('79f64f084f9043a9a1a2a5a026c71e77', '09b14b79f8bc46e39da369892a68c6a9') access_token = oauth.OAuthToken('c197c65ff203448fa102c8f3ee3b07e5', 'c9255a1ac98e4d2c994f1bea9f126ddc') parameters = {'nick': 'mingderwang', 'method': 'actor_get'} request = oauth.OAuthRequest.from_consumer_and_token( oauth_consumer=consumer, token=access_token, http_url='http://api.jaiku.com/json', http_method='POST', parameters=parameters) request.sign_request( oauth.OAuthSignatureMethod_HMAC_SHA1(), consumer, access_token) result = urllib2.urlopen(urllib2.Request( 'http://api.jaiku.com/json', request.to_postdata())) print result.read() result.close()

Whoa! That was *not* what I was expecting.

沒有留言: