Social Graph API をPythonでやってみた

気になったのでやってみた。
自分のtwitterのページでFollowされているのを取得する。

まずはベースとなるURLが

http://socialgraph.apis.google.com/lookup

こちらは、
GoogleCodeに記載されている。
http://code.google.com/apis/socialgraph/

で引数を決める。
今回使用したのは、

・pretty(インデント・改行される。)
・callback(コールバック関数を指定)
・edo(FollowしているURLを表示させる)

In [1]: base_url = ‘http://socialgraph.apis.google.com/lookup?q=http://twitter.com/kishir&pretty=1&callback=foo&
edo=1’

In [2]: html = opener.open(base_url).read()

In [3]: print html
foo({
 ”canonical_mapping”: {
  ”http://twitter.com/kishir”: “http://twitter.com/kishir”
 },
 ”nodes”: {
  ”http://twitter.com/kishir”: {
   ”attributes”: {
    ”url”: “http://twitter.com/kishir”,
    ”profile”: “http://twitter.com/kishir”,
    ”rss”: “http://twitter.com/statuses/user_timeline/kishir.rss”,
    ”atom”: “http://twitter.com/statuses/user_timeline/kishir.atom”
   },
   ”nodes_referenced”: {
    ”https://kishi-r.com/”: {
     ”types”: [
      ”me”
     ]
   },
    ”http://twitter.com/kano_e”: {
     ”types”: [
      ”contact”
     ]
    },
    ”http://twitter.com/soundkitchen”: {
     ”types”: [
      ”contact”
     ]
    },
    ”http://twitter.com/tasukuchan”: {
     ”types”: [
      ”contact”
     ]
    },
    ”http://twitter.com/yoshuki”: {
     ”types”: [
      ”contact”
     ]
    }
   }
  }
 }
});

なんでだろう?
Followされているユーザーが全て表示されない。
引数「q」に他のURLを加えると増えるのだが、
それも良くわからないなぁ~。

もうちょっと試してみるかな。

投稿者:

kishir

趣味: sk8, ピスト、ターンテーブル、レコード 仕事: Python, Objective-C, PHP, JavaScript

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です