Facebook JavaScript SDK的灵活提要对话框功能餐饮部

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Facebook JavaScript SDK的灵活提要对话框功能餐饮部相关的知识,希望对你有一定的参考价值。

A more flexible version of the 'official' Facebook feed dialog example.

"The Feed Dialog prompts the user to publish an individual story to a profile's feed. This does not require any extended permissions."

"The following simple javascript example demonstrates using the FB.ui method in the JavaScript SDK to use the Feed Dialog:"
  1. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
  2. <head>
  3. </head>
  4. <body>
  5.  
  6. <div id="fb-root"></div>
  7.  
  8. <script>
  9. window.fbAsyncInit = function() {
  10. FB.init({
  11. appId: "***********",
  12. channelURL : '//http://www.dr.dk/', // Channel File
  13. status: true,
  14. cookie: true,
  15. oauth : true, // enable OAuth 2.0
  16. xfbml: true
  17. });
  18. };
  19.  
  20. (function() {
  21. var e = document.createElement('script');
  22. e.async = true;
  23. e.src = document.location.protocol + '//connect.facebook.net/da_DK/all.js';
  24. document.getElementById('fb-root').appendChild(e);
  25. }());
  26.  
  27. function streampublish(obj) {
  28. // params: title, targethref, imgsrc, caption, description, message
  29.  
  30. // set default or passed parameters
  31. obj.title = (obj.title === undefined) ? "" : obj.title;
  32. obj.targethref = (obj.targethref === undefined) ? "" : obj.targethref;
  33. obj.imgsrc = (obj.imgsrc === undefined) ? "" : obj.imgsrc;
  34. obj.caption = (obj.caption === undefined) ? "" : obj.caption;
  35. obj.description = (obj.description === undefined) ? "" : obj.description;
  36. obj.message = (obj.message === undefined) ? "" : obj.message;
  37.  
  38. FB.ui(
  39. {
  40. method: 'feed',
  41. name: obj.title,
  42. link: obj.targethref,
  43. picture: obj.imgsrc,
  44. caption: obj.caption,
  45. description: obj.description,
  46. message: obj.message
  47. }/*,
  48. function(response) {
  49. if (response && response.post_id) {
  50. alert('Post was published.');
  51. } else {
  52. alert('Post was not published.');
  53. }
  54. }*/
  55. );
  56. }
  57.  
  58. </script>
  59. </body>
  60. </html>

以上是关于Facebook JavaScript SDK的灵活提要对话框功能餐饮部的主要内容,如果未能解决你的问题,请参考以下文章

html Facebook Javascript SDK演示

html 异步加载Facebook JavaScript SDK

Facebook javascript SDK 分享图片问题

Facebook 登录:如何将 JavaScript 与 PHP SDK 结合起来?

Facebook 权限对话框 (JavaScript sdk)

通过 Javascript SDK 共享 Facebook 链接返回错误 500