11月 14 2009
OpenSocial’s Architecture Slide
I’ve made a presentation about OpenSocial’s Architecture an event: Tokyo GTUG #4. Here I publish the slide I’ve used though it’s all in Japanese. Hope this will help someone.
11月 14 2009
I’ve made a presentation about OpenSocial’s Architecture an event: Tokyo GTUG #4. Here I publish the slide I’ve used though it’s all in Japanese. Hope this will help someone.
9月 11 2009
Snow Leopard has got PHP 5.3, so it’s nice to install Partuza and Shindig. Because you can do without installing entropy.
But I needed to do a little tweak to get MySQL work on Snow Leopard. Here’s a memo.
Download binary of MySQL from here. Choose Mac OS 10.5(x86_64) on download list close to the bottom.
Installing can be done only with GUI. Install Prefpane and Startup Item as well. Configure PATH too.
Create ~/.bash_profile and paste, or append following:
PATH=$PATH:/usr/local/mysql/bin export PATH
You can utilize it by doing:
> source ~/.bash_profile
You have to do following to get MySQL properly work on PHP:
> cd /usr/local/mysql > sudo ./script/mysql_install_db
then…
> sudo cp /etc/php.ini.default /etc/php/ini > sudo vim /etc/php.ini
change following part:
mysqli.default_socket = /var/mysql/mysql.sock
to something like this:
mysqli.default_socket = /tmp/mysql.sock
That’s it! Now you should be able to start MySQL from Preference Pane and see MySQL working on PHP.
Note: This makes Partuza working, but if you want to do something else, you may need some more work.
8月 29 2009
“Web will become more social” This has been what I kept telling people after 2005, when I’d joined goo. There’s so much things we can do when we make social graphs as a platform. First thing I tried was to make a social platform on a portal site, which turns out to be goo Home.
I already had an image of the future at that time: the social graph will be expanded to external web and it will tie any other services into one with social connections. It was before we laungh goo Home when Facebook emerged.
What Facebook was trying to do was not like what I initially imagined: getting external services into their service. It was totally opposite to what I was imagining, but I realized our ultimate goal must be the same. Making web social. After a few month, OpenSocial got announced.
OpenSocial decides its spec democratic and open. Openness is good. Imagine you want to tie 2 systems social. Needless to say, it’s easier when the spec is something standard. You can omit communication cost as well as technical endeavor.
On top of that, with open spec, a lot of product may be expected. Taking OpenSocial as example, there’s Yoichiro Tanaka’s OpenSocial Development Environment, OpenSocial Client Library, OAuth related libraries, OpenSocial Signed Request Library which I developed… Whole bunch of open source products help latter joining developers.
And the primal open source product among OpenSocial is Shindig, OpenSocial container’s reference implementation.
Shindig was my textbook to learn existing spec of OpenSocial. There was almost no one else in Japan who looked into Shindig, so I was invited to become an Google API Expert.
I’ve also wrote a lot of patches to Shindig on my way to developing goo Home. And 1 and half years have passed…
I have become a committer of Apache Shindig
I made my first contact with Mr. Chris Chabot who has been the main committer of PHP Shindig. I met him in person at Google IO 2008, occasionally chatting on messenger, he recommended me to become Shindig committer.
To become a committer in Apache Software Foundation, you have to get voted. And luckily, I was approved.
PHP Shindig is said to be used be more than 26 SNS with 5 million users. I was really excited to know that.
To me, OpenSocial is just a tool to make my ideal social web possible. But at least in Japan, there’s no other choice now and OpenSocial IS the standard. And Shindig which is used in mixi and goo, is the one which support its core.
I’m hoping to make Social Web happen in Japan and support it as a Shindig committer.
1月 12 2009
There’s some ways to get involved into OpenSocial
It is quite important to know architecture of OpenSocial whichever you choose. Especially when you choose to develop a gadget, there’ll be a lot of situations you get better result by knowing it.
This entry will try to explain what OpenSocial architecture is like by looking at reference implementation Shindig.
Did you know how iGoogle renders gadgets secure? In fact, gadgets are rendered inside iframes which is on different domain.
The reason for that is, security. It is quite dangerous to have third party scripts on same domain because it could steal cookies, do XSS, etc. I’ve written an article about Caja and there’s some details about same domain security (sorry only in japanese).

OpenSocial have 4 APIs People, Group, Activity and Persistent. Each of them is provided using RESTful in JSON, XML, AtomPub representation, or using RPC in JSON representation. Shindig’s JavaScript API is using RPC in JSON format.
I’ve mentioned about 2 domains on gadget architecture. In this situation, you know that API will be on Shindig domain because it’s using Ajax.

OK. Now you know the basic architecture. Let’s take look at the gadget rendering process.
First of all, you can’t render a gadget without request :) On iGoogle, user picks one’s favorite gadget from gadget directory, then display it on iGoogle page. The service has to render an iframe to display gadget, then, it needs to know what the gadget is like. Shindig has an API to return detailed information about the gadget. Metadata API.
Receiving request to metadata API, Shindig looks at its cache first of all. If no cache found, it fetches gadget XML and returns information to the service.
Once getting information about the gadget, service will render an iframe to display the gadget. By doing this, Shindig will receive request to render the gadget.
Gadget XML’s contents will be rendered as it is basically, but it will be convinient if you know that:
That’s all how gadgets are rendered. You can check that requests are sent to Shindig when trying out with Firebug.
If you want to use External APIs, you can use gadgets.io.makeRequest. If you choose FEED as content type, JavaScript API will return abstract object as response regardless of content format(RSS, RDF or Atom). If you choose JSON, JS API will return JSON object even if the returned content is stringified.
You have a few choices on security too.
Regular Request is chosen when you don’t need any kind of authorizations on accessing API. Signed Request is OAuth Consumer Request in other words. By using it, external server can restrict requests from approved gadgets. OAuth is OAuth Core in other words. External server can know who’s accessing to the API using credential securely, on top of assuring that it’s coming from approved server.
Please refer to articles like this or this, I’ve written regarding OAuth. (If you can read japanese! :P)
Note that all external accesses are using proxy and Shindig has a strong cache functionality. You will have to take care of caches when developing a gadget. I’ll explain in detail about caches on coming entry.
6月 03 2008
OpenSocialのコンテナと言えばShindigですが、PHP版は既にOpenSocial v0.7への対応を完了しています。Partuza!はPHP版Shindigの開発者であるChris Chabot氏がオープンソースで開発したShindig対応SNSです。
Shindigがコンテナなのに、じゃあPartuza!は何をするの?と思われるかもしれません。今回はインストール方法と、Shindigとの関係について解説します。
Shindigのインストール方法は以前解説しましたので、ここでは割愛します。仮に、Shindigが~/shindig配下にインストールされ、http://localhost:8080/gadgets/…でアクセスできるものとします。
まず、環境としてApache、PHP5(要mcrypt)、MySQL5が必須となります。
Google CodeのレポジトリからSVNでチェックアウトします。
> svn checkout http://partuza.googlecode.com/svn/trunk/ ~/partuza
適当なデータベース名、ユーザー名、パスワードで空のDBを作ってください。ひとまずここではそれぞれ、partuza、root、パスワードなしとします。この状態で、~/partuza/partuza.sqlをダンプします。
> mysql -u root partuza < partuza.sql
Apacheの設定(httpd.conf)でDocumentRootを~/partuza/htmlに設定し、http://localhost/でアクセスできるようにします。もちろん、Shindigとは別ドメインを用意する必要がありますので、バーチャルホストを使う等してください。
~/partuza/html/config.phpを編集します。ここでは先程作成したデータベース関連の情報とガジェットサーバーのルートURL(gadget_server)を設定します。ガジェットサーバーのURLが、ここではShindigのURLとなりますので、http://localhost:8080/になります。
~/partuza/Shindig/PartuzaDbFetcher.phpと~/partuza/Shindig/PartuzaHandler.phpを~/shindig/php/src/socialにコピーします。
> cp ~/partuza/Shindig/Partuza* ~/shindig/php/src/social
~/shindig/php/src/social/PartuzaDbFetcher.phpにもデータベース関連の情報があるので修正します。加えてShindigがデータベースハンドラを利用するよう、~/shindig/php/config.phpも修正します。ここでは、”handlers => PartuzaHandler”としてください。
これで一通りの準備は完了。http://localhost/にアクセスしてウェルカム画面が出れば成功です。このまま登録し、Orkutライクな一般的なSNSとして利用することができます。
OpenSocialのガジェットがiframeを介して表示されていることは以前も解説しましたが、簡単に言ってしまえば、iframeの手前がPartuza、後ろがShindigになります。Shindigでは以前から下記のURLにアクセスすることで簡易的なHTMLからOpenSocialぽい表示を行うことはできていましたが、Partuzaを使うことで完全なSNSとなります。
http://localhost:8080/gadgets/files/samplecontainer/samplecontainer.htmlとはいえ、PartuzaHandlerを指定したところからも想像できるように、データベースは共有されます。なお、Chris Chabot氏のサイトで実際に動いているものを確認することができます。
Partuza!を使うことで、どうすればShindigをSNSに組み込むことができるかの解析をすることができるだけでなく、そのままちょっとしたSNSを開発することもできてしまいます。ぜひお試しください。