2013-03-25 125 views
0

我很努力地把帖子貼到牆上的功能到現有的一段代碼? 它工作正常登錄和獲取表單提交的電子郵件,我想它張貼到牆上登錄以及!以簡單的方式可能。 看到它在行動中的網址是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

回答

0

嘗試類似的東西

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