0

這是一個非常新手的問題,我無法找到解決方案,我花了很多時間閱讀他們的官方文檔,但它都是徒勞的,所以我有作爲最後的手段來到這裏。
什麼,我試圖做
我要發佈我自定義的故事在我的時間表,

1)我創建了一個自定義的故事
2)試圖與共享對話框[分享它沒有工作],並嘗試過api調用。Facebook在我的時間軸上使用javascript sdk分享自定義故事

<div id="fb-root"></div> 

<!-- facebook code starts here --> 

<script> 
    function statusChangeCallback(response) { 
    console.log('statusChangeCallback'); 
    console.log(response); 


    function checkLoginState() { 
    FB.getLoginStatus(function(response) { 
     statusChangeCallback(response); 
    }); 
    } 

    window.fbAsyncInit = function() { 
    FB.init({ 
    appId  : xxxxx[correctly used app id], 
    cookie  : true, // enable cookies to allow the server to access 
    status  : true,   
    xfbml  : true, // parse social plugins on this page 
    version : 'v2.0' // use version 2.0 
    }); 



    FB.getLoginStatus(function(response) { 
    statusChangeCallback(response); 
    }); 




    FB.api(
      'me/objects/restaurant.restaurant', 
      'post', 
      { 
      app_id: xxxxx[correctly used app id], 
      type: "restaurant.restaurant", 
      url: "http://samples.ogp.me/440002909390231", 
      title: "Sample Restaurant", 
      image:"https://static.ak.fbcdn.net/images/devsite/attachment_blank.png", 
      description: "This place rocks", 
      contact_info: "http://www.facebook.com", 
      location: "-122.148283" 
      }, 
      function(response) { 
      // handle the response 
      } 
    ); 


    FB.api(
      'me/testxdev:eat', 
      'post', 
      { 
      restaurant: "http://samples.ogp.me/440002909390231" 
      }, 
      function(response) { 
      // handle the response 
      } 
     ); 


    };//********END OF FUNCTION ENCLOSING INIT()*********** 

    // Load the SDK asynchronously 
    (function(d, s, id) { 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) return; 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/sdk/debug.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 


</script> 

<div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div> 


<!-- End of facebook code--> 

回答

1

我能解決我自己的問題,我也發佈瞭解決方案,以便別人不會有這麼難的時候。

<div id="fb-root"></div> 
<!-- facebook code starts here --> 

<script> 

    function statusChangeCallback(response) { 


    if (response.status === 'connected') { 



    FB.api('/me', function(response) { 
     console.log("here"); 
      console.log(JSON.stringify(response)); 
}); 

    FB.api(
     '/me/objects/restaurant.restaurant', 
     'post', 
     { 
      app_id: "[your app id]", 
      type: "restaurant.restaurant", 
      url: "http://samples.ogp.me/440002909390231", 
      title: "Sample Restaurant", 
      image: "https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png", 
      description: "This place rocks", 
      contact_info: "http://www.facebook.com", 
      location: "-122.148283" 
     }, 
     function(response) { 
      // handle the response[this helped a lot] 
      console.log(JSON.stringify(response)); 

     } 
     ); 

      FB.api(
       '/me/testxdev:eat', 
       'post', 
       { 
      restaurant: "http://samples.ogp.me/440002909390231" 
       }, 
       function(response) { 
      // handle the response 
       console.log("the action response "+response); 
       console.log(JSON.stringify(response)); 

       } 
      ); 

    } else if (response.status === 'not_authorized') { 
     document.getElementById('status').innerHTML = 'Please log ' + 
     'into this app.'; 
    } else { 
     document.getElementById('status').innerHTML = 'Please log ' + 
     'into Facebook.'; 
    } 
    } 


    function checkLoginState() { 
    FB.getLoginStatus(function(response) { 
     statusChangeCallback(response); 
    }); 
    } 

    window.fbAsyncInit = function() { 
    FB.init({ 
    appId  : "[your app id]", 
    cookie  : true, 
    status  : true,  
    xfbml  : true, 
    version : 'v2.0' 
    }); 

    FB.getLoginStatus(function(response) { 
    statusChangeCallback(response); 
    }); 



    }; 

    // Load the SDK asynchronously 
    (function(d, s, id) { 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) return; 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/sdk/debug.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 


</script> 


<fb:login-button scope="public_profile,email,publish_actions", 
    auth_type: 'rerequest' onlogin="checkLoginState();"> 
</fb:login-button> 
<div id="status"></div> 
<div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div> 


<!-- End of facebook code--> 

上面的代碼工作正常[代碼是從一個自定義創建的故事],主要的問題是,通過在訊息的分享它的默認不會出現在時間軸[AS應用程序是開發模式],因此查看帖子去查看最近的活動日誌。它必須在那裏可見。 如果你想後出現下的應用信息中心的地位和審查程序的可見性設置爲yes,在時間軸上

截至2014年,如果你想張貼任何用戶[除了應用程序註冊開發者]時間表你需要Facebook的權限,即應用程序需要提交批准請參考以下鏈接https://developers.facebook.com/docs/facebook-login/permissions/v2.0

你可以檢查它是否正確下面的概述部分。

相關問題