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

时间:2010-12-09 08:35:04

标签: 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.');
     }
   }
 );
}

1 个答案:

答案 0 :(得分:7)

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.';
   });
};