javascript - 你如何使用 FB.UI 自动发布?

标签 javascript facebook facebook-graph-api

我有 stream_publish 权限,但它仍然会弹出一个对话框,而且似乎没有任何方法可以传递自动发布 bool 值(就像在图形 api 之前一样)。

编辑:还尝试使用 stream_publish 进行 offline_access。

关于如何让它发挥作用的任何想法?


function streamPublish(imageUrl, imageHref, attachName, attachHref, attachCaption) {
 FB.ui(
   {
     method: 'stream.publish',
     message: '',
     attachment: {
       name: attachName,
       caption: attachCaption,
       description: (
         ''
       ),
       href: attachHref,
       media: [
         {
           type: 'image',
           href: imageHref,
           src: imageUrl
         }
        ]
     }
   },
   function(response) {
     if (response && response.post_id) {
       //alert('Post was published.');
     } else {
       //alert('Post was not published.');
     }
   }
 );
}

最佳答案

http://www.takwing.idv.hk/tech/fb_dev/jssdk/learning_jssdk_12.html

如果您拥有与 FB.UI 不同的权限,以下内容将自动发布 :)


function publishPost(session) {
   var publish = {
     method: 'stream.publish',
     message: 'is learning how to develop Facebook apps.',
     picture : 'http://www.takwing.idv.hk/facebook/demoapp_jssdk/img/logo.gif',
     link : 'http://www.takwing.idv.hk/facebook/demoapp_jssdk/',
     name: 'This is my demo Facebook application (JS SDK)!',
     caption: 'Caption of the Post',
     description: 'It is fun to write Facebook App!',
     actions : { name : 'Start Learning', link : 'http://www.takwing.idv.hk/tech/fb_dev/index.php'}
   };

   FB.api('/me/feed', 'POST', publish, function(response) {  
       document.getElementById('confirmMsg').innerHTML = 
              'A post had just been published into the stream on your wall.';
   });
};  

关于javascript - 你如何使用 FB.UI 自动发布?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4396269/

相关文章:

javascript - JRE 与 Node 性能

javascript - 单击第二个后取消选中第一个过滤器

javascript - 如何在 Angular 2 中绕过路由器

javascript - 来自 webapp 的 Facebook 分享对话框深度链接

ruby-on-rails - FbGraph OAuthException 无效的 OAuth 访问 token

javascript - 如何从平面 JavaScript 数组创建分层 HTML 结构?

iOS 构建后 Facebook 登录不起作用

php - 无法打开流 : HTTP request failed! HTTP/1.0 400 错误请求

php - 如何使用 CodeIgniter 3.1.0 将 Facebook 用户基本信息保存到数据库

facebook - 使用 Facebook 身份验证登录时出现 Typescript 编译器错误