2010年5月30日 星期日
2010年2月4日 星期四
2010年1月23日 星期六
OAuth to acess JaiKu in 2 min
Step 1. You have to have a JaiKu account. Then, get you customer "key" and "secret"
Here is where you can get your key and secret. (http://www.jaiku.com/api/keys)
Step 2. Use "OAuth Test Client" for following steps.
A. Use your customer "Key" and "Secret" with endpoint "http://www.jaiku.com/api/request_token" to and click on "reqest_token" button to get your Request Token as follows;
oauth_token_secret=efc0a966fcb64fdf80b639b3f814a640&oauth_token=f84d993f9046417aa7370e48b18a4f50
B. You can't use this token now, because it is not Authorized by "JaiKu.com" yet.
So, copy oauth_token and oauth_token_secret to "OAuth Test Client" again and change the endporint to "http://www.jaiku.com/api/authorize" and press "authorize" button.
You will see a web page asking you to press "Authorize" this token.
If you agree with that. This token is authorized. But you have to use this authorized token to get the Access Token.
C. Use "OAuth Test Client" to get your Access Token again. Change your endpoint to "http://www.jaiku.com/api/access_token" and click on "access token" button.
or you can see your Activated API Tokens in (http://www.jaiku.com/api/tokens)
Step 3. What API and URL do you want to access JaiKu.com? and prepare a Python code to access it.
Python Code: (test.py)
1 import urllib2
2 from oauth import oauth
3 consumer = oauth.OAuthConsumer('79f64f084f9043a9a1a2a5a026c71e77', '09b14b79f8bc46e39da369892a68c6a9')
4 access_token = oauth.OAuthToken('6ef9aeacf88c4d5296e340b09a708521', '1ae85c5bcdcc4827aa3f37902feb7f2a')
5 parameters = {'nick': 'mingderwang', 'method': 'actor_get'}
6 request = oauth.OAuthRequest.from_consumer_and_token(
7 oauth_consumer=consumer,
8 token=access_token,
9 http_url='http://api.jaiku.com/json',
10 http_method='POST',
11 parameters=parameters)
12 request.sign_request(
13 oauth.OAuthSignatureMethod_HMAC_SHA1(),
14 consumer,
15 access_token)
16 result = urllib2.urlopen(urllib2.Request(
17 'http://api.jaiku.com/json',
18 request.to_postdata()))
19 print result.read()
20 result.close()
Step 4. Python test.py to get result as follows;
{"status": "ok", "rv": {"actor": {"avatar_updated_at": "2009-10-28 08:37:49.560840", "privacy": 3, "extra": {"family_name": "Wang", "icon": "mingderwang@jaiku.com/avatar_96e850b8f9dc4814bab9130a9d4a0d4a", "contact_count": 1, "given_name": "Ming-der"}, "nick": "mingderwang@jaiku.com", "deleted_at": null, "type": "user"}}, "servertime": "2010-01-23 10:46:01.523307"}
Where, you want to get JSON format data by using actor_get API with a nick name called "mingderwang" (my account).
use POST http command and OAuthSignatureMethod is HMAC_SHA1
Step 5. If you try it again for other API, make sure your access tokens are still ACTIVATED.
see here (http://www.jaiku.com/api/tokens)
Good luck!
If you still have any question (email me ming@katdc.com)
OAuth in JaiKu
http://www.jaiku.com/api/docs/authentication
where you need to use custom key and custom secret first from following URL:
(get your account in Jaiku first).
then you can use customer key, and secret, with the endpoint and got following oauth_token and oauth_token_secret to use "oauth Test client" (http://term.ie/oauth/example/client.php)
oauth_token_secret=c9255a1ac98e4d2c994f1bea9f126ddc&oauth_token=c197c65ff203448fa102c8f3ee3b07e5
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.
2010年1月19日 星期二
2008年12月18日 星期四
2008年7月29日 星期二
2008年7月28日 星期一
Google I/O 2008 - Painless Python Part 1 of 2
If anyone need Chinese translation for this trainning material, please email me (mingderwang@gmail.com)
2008年6月25日 星期三
Qt, 我建議用Qt設計家來設計有GUI (繪圖使用者介面)的程式
2008年6月24日 星期二
目前全世界有多少個Python 的packages 嗎?
import from where? 有4310個 packages 你可以安裝和使用.
這就是Python 好用的地方. 當然絕大部份還是beta, 但很多beta 有source code可參考.
希望以後能自動eggs.
Python就更強了.
這就是Python 好用的地方. 當然絕大部份還是beta, 但很多beta 有source code可參考.
希望以後能自動eggs.
Python就更強了.
訂閱:
文章 (Atom)





