pythonでOpenSocial
http://d.hatena.ne.jp/asannou/20091109
security tokenをgadgetから渡せば、外部サーバーからでもREST APIでopensocial containerにアクセスできるという話なので、pythonでも試してみました。
python版はgoogleの中の人が作っているものがあるので、それを使いました。
http://code.google.com/p/opensocial-python-client/
import opensocial import logging st = 'xxx' config = opensocial.ContainerConfig( security_token=st, security_token_param = 'st', server_rest_base = 'http://app0.mixi-platform.com/social/data') container = opensocial.ContainerContext(config) # 個人の情報の取得 person = container.fetch_person('@viewer') logging.warn(person['id']) logging.warn(person['nickname']) # 友達取得の例 friends = container.fetch_friends('@viewer') for friend in friends: logging.warn(friend['id']) logging.warn(friend['nickname'])
これで無事にアクセスできました。containerを作るときに、security_token_paramとserver_rest_baseを設定するのがポイントです。
# opensocial-client-pythonはGAE上でも動作しました。これでマリモアプリ作り放題ですね。