facebookアプリで使うのダイアログって別にダイアログじゃなくてもiframeでも使えるよ
ちゃんとしたFacebookアプリ作る時はFacebookのダイアログは嫌でも使わないといけないと思いますが、
Dialogs Overview
ダイアログの枠のデザインがアプリにマッチしなかったり、画面設計、画面フロー的にダイアログだとスムーズじゃない事もあると思います。
そんな時の為に、ダイアログはiframeでもpageでも使えるって事も覚えておくといざという時に役立つかもです。
(pageってのはこんな感じで完全にアプリの外に一回出る感じなので、逆に使いどころ難しいかな http://www.facebook.com/dialog/feed?app_id=123050457758183&redirect_uri=http://www.example.com/response/)
iframeだと、こんな感じでアプリ内の任意の場所に埋め込む形で結構使えると思います。
デモ
http://www.fbrell.com/saved/c7e6e26b1fff73497077edd078da2db3
iframeの動的生成はブラウザによって挙動が違ったりしてなんかめんどくさい事が必要なのか知らないですけど、↓のgithubのコメントのあたりを参考にすると大丈夫だと思います。
FacebookのJavaScript SDKの下品なコメントが格好良すぎて惚れた件
一応コード例こんな感じ
<h1>apprequst iframe test</h1> <iframe src="http://iq148.com/" id="apprequest_iframe" width="600" height="300"></iframe> <h1>feed iframe test</h1> <iframe src="http://iq148.com/" id="feed_iframe" width="600" height="300"></iframe> <h1>send iframe test</h1> <iframe src="http://iq148.com/" id="send_iframe" width="600" height="300"></iframe> <script> //エスケープとか適当にしてくれ var appid = "app idです。"; var link = "シェアするリンク"; var redirect_uri = "処理後戻り先URL"; var text = "メッセージとか"; FB.login(function(response) { if(response.authResponse){ document.getElementById('apprequest_iframe').src="https://www.facebook.com/dialog/apprequests?app_id=" + appid + "&message=" + text + "&link=" + link + "&redirect_uri=" + redirect_uri + "&display=iframe&access_token=" + response.authResponse.accessToken; document.getElementById('feed_iframe').src="https://www.facebook.com/dialog/feed?app_id=" + appid + "&name=" + text + "&link=" + link + "&redirect_uri=" + redirect_uri + "&display=iframe&access_token=" + response.authResponse.accessToken; document.getElementById('send_iframe').src="https://www.facebook.com/dialog/send?app_id=" + appid + "&name=" + text + "&link=" + link + "&redirect_uri=" + redirect_uri + "&display=iframe&access_token=" + response.authResponse.accessToken; } else{ alert("not auth..."); } }) </script>
Facebook開発者サポートへのバグ報告がお洒落すぎて惚れた件
https://developers.facebook.com/bugs/214544508642763
再現手順
- サポートにメールする
- 永遠に待ち続ける
期待する挙動
サポートからの返信
実際の挙動
永遠と返信を待ち続ける
androidのブラウザのzoomを無効にするには
アンドロイドのbrowserで右下にズームボタンが表示されないようにするには、
viewportにuser-scalable=noじゃなくて
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"/>
RubyでいっぱいProcを渡しても、スレッドをつくりすぎないようにちょっとずつ並列実行してくれるヤツ
2011/12/10昼ごろ追記
つか、これじゃダメっぽい。実行されずに終わるスレッドがたまにある。joinの実装?
2011/12/10 18:45 join修正した
2011/12/10 20:40 callのところに例外処理
2011/12/12 Procじゃなくてblockに変更してみた
名前がイケてない
class ThreadCommander require 'thread' def initialize size = 50 @q = SizedQueue.new size @ts = {} end def push &block @q.push block.object_id t = Thread.start do begin yield rescue Exception => e #なんか例外処理 end @q.pop end @ts[:t.object_id] = t end def join while !@q.empty? @ts.each do |k, v| v.join @ts.delete(k) end Thread.pass end end end tq = ThreadCommander.new 10 puts "start." (1..100).to_a.each do |i| tq.push {sleep rand; puts i} puts "." end puts "running." tq.join puts "end."
FacebookのJavaScript SDKの下品なコメントが格好良すぎて惚れた件
https://github.com/facebook/connect-js/blob/master/src/core/content.js#L113
// Dear IE, screw you. Only works with the magical incantations. // Dear FF, screw you too. Needs src _after_ DOM insertion. // Dear Webkit, you're okay. Works either way. var guid = FB.guid(), …続く
親愛なるIEへ、 死ね。 謎の呪文を使わないと動かない…
親愛なるFFへ、 お前も死ね。 DOM挿入後にsrc設定必要
親愛なるWebkitへ、 お前はいいだろう。 どっちでも動く。
Rails3.1でRDBMS(active_record)を使わない場合
application.rbのrails/allを読み込んでいるところを修正します。
#require 'rails/all' %w( action_controller action_mailer active_resource rails/test_unit sprockets ).each do |framework| begin require "#{framework}/railtie" rescue LoadError end end
active_recordを外しますが、
Rails3.1からsprocketsが追加になっているので注意(3.0までは無かった)
これが無いとassets pipelineが動いてくれません