
Facebook JavaScript SDKで、パーミッションを許可するダイアログを表示する方法です。
FB.ulメソッドを使います。
第一引数にはパラメータを、第二引数にはコールバック関数を渡します。
sample.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <html> <head> <title>sample</title> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId: 'YOUR_APP_ID', status: true, cookie: true, xfbml: true }); // パーミッションを許可するダイアログを表示する FB.ui( { method: "permissions.request", perms: 'publish_actions, user_likes' }, function(response) { console.log(response); } ); }; (function() { var e = document.createElement('script'); e.type = 'text/javascript'; e.src = document.location.protocol + '//connect.facebook.net/ja_JP/all.js'; e.async = false; document.getElementById('fb-root').appendChild(e); }()); </script> </body> </html> |