- 9月 29,09
- Category :Computers & Internet
@nakajimanさんに、gooホームならOAuth認証を使えると教えてもらったので、gooホームにコンテナを移す事に。
mixiアプリよアディオス!
認証までなら、ExampleFriendFeedOAuthの通りにやればできます。
認証完了までに、知ったこと。メモ〆
twitterでOAuthを使う方法(その1:認証まで)ここで、OAuth認証の一連の流れを把握。図もあってわかりやすかった。
OAuthを使用するためにはhttp://twitter.com/oauth_clientsで登録を行う。
登録に必要な項目のCallback URLには、ガジェットxmlのURL。
ここで登録後にもらえるConsumer key, Consumer secretは後で使用する。
ガジェットxmlにOAuthのサービスを追加
<OAuth>
<Service name="twitter">
<Request url="http://twitter.com/oauth/request_token" param_location="uri-query" />
<Authorization url="http://twitter.com/oauth/authorize" />
<Access url="http://twitter.com/oauth/access_token" param_location="uri-query" method="GET" />
</Service>
</OAuth>
OAuthの追加場所は/ModulePrefs/配下
/ModulePrefs/OAuth/Service@nameは’twitter’以外だと、動かなかった(oauthApprovalUrlを取得出来なかった)ので固定なのかな?
ガジェットxmlをgooホームサンドボックスに登録。
署名方式の設定
OAuth TypeはHMAC-SHA1を選択し、Consumer key, Consumer secretを登録する。
そのあとはガジェットxmlを作り上げるのみ。
$.ajax({
type: 'get',
url: 'http://twitter.com/statuses/friends_timeline.json',
dataType: 'json',
oauth: 'twitter',
success: function(data, status) {
console.info(data, status);
},
error: function(xhr, status, e) {
if (status == 'oauth')
$('<a href="#signin"/>')
.text('Sign in with twitter')
.click(function() {
$(this).parents('table').remove(); // remove minimessage
$.oauth('twitter');//認証ページへ
return false;
}).minimessage();
}
});
サンプルそのままです。
<Require feature="minimessage" /> <Require feature="oauthpopup"/>
このoauthpopupを忘れて、3時間ほど動きませんでしたorz
ちゃんとAjaxOAuthのドキュメントやサンプルにはしっかり書いているんですがねw
mixiアプリでoauthpopupのフィーチャーが非対応だったので外したことを忘れてました。
これで実行するとHTTPステータスコードは200が返って来てたので、認証成功。
あとは、friends_timelineなり取得すると一応の目標は達成することに。(まだ出来てないw
@noblejasperさん、@nakajimanに沢山のサポートをしてもらいました。
ここにて、感謝の意を表します。
もっと精進しよう!!
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://clare-chronicle.net/2009/09/opensocial-jquery%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6goo%e3%83%9b%e3%83%bc%e3%83%a0%e3%82%ac%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88%e3%82%92%e4%bd%9c%e3%82%8d%e3%81%86%e3%81%a8%e3%81%97%e3%81%a6%e3%81%bf/trackback/
- Listed below are links to weblogs that reference
- opensocial-jqueryを使ってgooホームガジェットを作ろうとしてみた-OAuth認証- from Clare Chronicle