facebook js sdk发贴到墙

问题描述:

我很努力地把帖子贴到墙上的功能到现有的一段代码? 它工作正常登录和获取表单提交的电子邮件,我想它张贴到墙上登录以及!以简单的方式可能。 看到它在行动中的网址是http://lproctor.co.uk/facebook js sdk发贴到墙

// The facebook JavaScript SDK to log in to FB 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId: '<?php echo $facebook->getAppID() ?>', 
      cookie: true, 
      xfbml: true, 
      oauth: true 
     }); 
     FB.Event.subscribe('auth.login', function(response) { 
      window.location.reload(); 
     }); 
     FB.Event.subscribe('auth.logout', function(response) { 
      window.location.reload(); 
     }); 
     }; 
     (function() { 
     var e = document.createElement('script'); e.async = true; 
     e.src = document.location.protocol + 
      '//connect.facebook.net/en_US/all.js'; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 
    FB.ui(
    { 
    method: 'feed', 
    name: 'The Facebook SDK for Javascript', 
    caption: 'Bringing Facebook to the desktop and mobile web', 
    description: (
     'A small JavaScript library that allows you to harness ' + 
     'the power of Facebook, bringing the user\'s identity, ' + 
     'social graph and distribution power to your site.' 
    ), 
    link: 'https://developers.facebook.com/docs/reference/javascript/', 
    picture: 'http://www.fbrell.com/public/f8.jpg' 
    }, 
    function(response) { 
    if (response && response.post_id) { 
     alert('Post was published.'); 
    } else { 
     alert('Post was not published.'); 
    } 
    } 
); 

现在用

 <script type="text/javascript"> 
    // The facebook JavaScript SDK to log in to FB 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId: '<?php echo $facebook->getAppID() ?>', 
      cookie: true, 
      xfbml: true, 
      oauth: true 
     }); 
    FB.ui(
    { 
    method: 'feed', 
     name: 'Facebook name', 
    link: 'http://lproctor.co.uk/', 
    picture: 'http://lproctor.co.uk/logo.jpg', 
    caption: 'facebook caption', 
    description: ' facebook description facebook description facebook description facebook description', 
    message: 'Facebook message!' 
    }, 
    function(response) { 
    if (response && response.post_id) { 
     alert('Post was published.'); 
    } else { 
     alert('Post was not published.'); 
    } 
    } 
); 
     FB.Event.subscribe('auth.login', function(response) { 
      window.location.reload(); 
     }); 
     FB.Event.subscribe('auth.logout', function(response) { 
      window.location.reload(); 
     }); 
     }; 


     (function() { 
     var e = document.createElement('script'); e.async = true; 
     e.src = document.location.protocol + 
      '//connect.facebook.net/en_US/all.js'; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 


    </script> 
+0

请描述它是如何失败的。浏览器的JavaScript控制台中是否出现错误? – 2013-03-25 13:47:22

+0

没有失败的错误。登录工作正常,电子邮件和名称被收集到表单中,它只是不贴到墙上?SRY有错误 – 2013-03-25 13:57:40

+0

FB没有被定义! FB.api('/ me/feed','post',{message:body},function(response){ – 2013-03-25 14:00:17

尝试类似的东西

FB.getLoginStatus(function(response) { 
    if (response.status === 'connected') { 
     // connected 
    } else if (response.status === 'not_authorized') { 
     // not_authorized 
     login(); 
    } else { 
     // not_logged_in 
     login(); 
    } 
}); 
}; 
+0

um come again ?请参阅修改后的代码和问题是东去重新创建lproctor.co.uk – 2013-03-25 15:25:57