2014-03-03 15 views
1

我有一個Facebook模式對話框,我想放在一個自定義模式對話框(作爲一個html元素)。這是我到目前爲止有:如何把Facebook對話框放在一個自定義模式/ html

對於Facebook的對話框:

$(document).ready(function(){ 
window.fbAsyncInit = function() { 
    FB.init({ appId: '***************', cookie: true, xfbml: true, oauth: true }); 

    // *** here is my code *** 
    if (typeof facebookInit == 'function') { 
     facebookInit(); 
    } 
}; 

(function(d){ 
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    d.getElementsByTagName('head')[0].appendChild(js); 
}(document)); 

function facebookInit() { 
    FB.ui({ 
    url : 'http://www.google.com', 
    method: 'feed', 
    name: 'The name', 
    link: 'crowd.com', 
    caption: 'An example caption', 
}, function (response) { 
    if (response && response.post_id) { 
     alert('Post was published.'); 
    } else { 
     alert('Post was not published.'); 
    } 
}); 
} 
}); 

對於模態:

<div id="myModal1new" class="modal1 hide welcome-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
</div> 

<div class="modal-header"></div> 
      <div class="modal-body"> 
       <div id="fb-root"></div> 
      </div> 

反正我有可以結合這兩種(放置自定義內的FB對話模式)?也許有一個iframe的種類?先謝謝你。

+0

我們可以有一個操場嗎? – Ravimallya

回答

3

壞消息,你不能做到這一點,所有的URL Facebook的具有共享像sharer.php和網址供對話框,像這樣的:

https://www.facebook.com/dialog/feed? 
    app_id=145634995501895 
    &display=page&caption=An%20example%20caption 
    &link=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fdialogs%2F 
    &redirect_uri=https://developers.facebook.com/tools/explorer 

不會在iframe中呈現,因爲Facebook的阻止所有內容在一個內部呈現。下面是被拋出的錯誤,當您嘗試創建與Facebook內容的iframe:既然你不能使用iframe的

Refused to display 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.google.com' in a frame because it set 'X-Frame-Options' to 'DENY'. 

和飼料對話框打開一個新窗口每一次,你可以有所作爲的唯一途徑類似的是創建你自己的「共享對話框」,但記住這個工作,你將不得不要求用戶代表他們發佈權限。

+0

我將如何去創建我自己的共享對話框? – user1072337

+0

你需要知道什麼?這些文檔是否回答你的問題? https://developers.facebook.com/docs/web/share和https://developers.facebook.com/docs/graph-api/using-graph-api/#publishing –

相關問題