Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 许多FACEBOOK在同一页面上共享按钮?_Html_Django_Facebook_Share_Facebook Like - Fatal编程技术网

Html 许多FACEBOOK在同一页面上共享按钮?

Html 许多FACEBOOK在同一页面上共享按钮?,html,django,facebook,share,facebook-like,Html,Django,Facebook,Share,Facebook Like,我使用javascript在我的页面中实现了facebook共享按钮,如下所示: <script type="text/javascript"> $(document).ready(function(){ $('#share_button').click(function(e){ e.preventDefault(); FB.ui( { method: 'feed

我使用javascript在我的页面中实现了facebook共享按钮,如下所示:

<script type="text/javascript">
$(document).ready(function(){
        $('#share_button').click(function(e){
            e.preventDefault(); 
            FB.ui(
            {
                method: 'feed',
                name: "{{ user_name }}'s FOF",
                link: "https://www.example.com/uploader/{{current_fof}}/share_fof/",
                picture: imgsArray[0].src,
                caption: window.location.href,
                description: 'This FOF was taken by {{ user_name }}',
                message: ''
            });     
        });
    });
</script>


<div class="share"> <img src = "{{ STATIC_URL }}images/share_facebook.png" id="share_button" type='button_count'></div>

$(文档).ready(函数(){
$(“#共享按钮”)。单击(函数(e){
e、 预防默认值();
FB.ui(
{
方法:“提要”,
名称:“{user_name}}的FOF”,
链接:“https://www.example.com/uploader/{{current_fof}}/share_fof/“,
图片:imgsArray[0].src,
标题:window.location.href,
description:'此FOF由{{user_name}}获取,
消息:“”
});     
});
});
它工作得很好,但是现在我想在同一个页面中放置许多帖子,并为每个帖子使用不同的共享按钮(每个FB共享按钮应有不同的链接、标题和图像)。有什么想法吗

它使用FB API使用like按钮工作:

<div class="fb-like" data-href="https://www.example.com/uploader/{{current_fof}}/share_fof/" data-send="true" data-layout="button_count" data-width="450" data-show-faces="false" data-font="arial"></div>  

但是如何使用share_按钮做类似的事情呢?有什么想法吗

干杯,

为每个“共享”按钮指定不同的id,并更改每个项目的其他选项(不同的链接、标题和图像)。
例如:

<script type="text/javascript">
$(document).ready(function(){
        $('#share_button1').click(function(e){
            e.preventDefault(); 
            FB.ui(
            {
                method: 'feed',
                name: "{{ user_name }}'s FOF",
                link: "https://mysite.com/uploader/{{current_fof}}/share_fof/",
                picture: imgsArray[0].src,
                caption: window.location.href,
                description: 'This FOF was taken by {{ user_name }}',
                message: ''
            });     
        });
        $('#share_button2').click(function(e){
            e.preventDefault(); 
            FB.ui(
            {
                method: 'feed',
                name: "{{ user_name }}'s FOF",
                link: "https://mysite.com/uploader/{{current_fof}}/share_fof/",
                picture: imgsArray[0].src,
                caption: window.location.href,
                description: 'This FOF was taken by {{ user_name }}',
                message: ''
            });     
        });          
        $('#share_button3').click(function(e){
            e.preventDefault(); 
            FB.ui(
            {
                method: 'feed',
                name: "{{ user_name }}'s FOF",
                link: "https://mysite.com/uploader/{{current_fof}}/share_fof/",
                picture: imgsArray[0].src,
                caption: window.location.href,
                description: 'This FOF was taken by {{ user_name }}',
                message: ''
            });     
        });
});
</script>

$(文档).ready(函数(){
$(“#共享_按钮1”)。单击(函数(e){
e、 预防默认值();
FB.ui(
{
方法:“提要”,
名称:“{user_name}}的FOF”,
链接:“https://mysite.com/uploader/{{current_fof}}/share_fof/“,
图片:imgsArray[0].src,
标题:window.location.href,
description:'此FOF由{{user_name}}获取,
消息:“”
});     
});
$(“#共享_按钮2”)。单击(函数(e){
e、 预防默认值();
FB.ui(
{
方法:“提要”,
名称:“{user_name}}的FOF”,
链接:“https://mysite.com/uploader/{{current_fof}}/share_fof/“,
图片:imgsArray[0].src,
标题:window.location.href,
description:'此FOF由{{user_name}}获取,
消息:“”
});     
});          
$(“#共享_按钮3”)。单击(函数(e){
e、 预防默认值();
FB.ui(
{
方法:“提要”,
名称:“{user_name}}的FOF”,
链接:“https://mysite.com/uploader/{{current_fof}}/share_fof/“,
图片:imgsArray[0].src,
标题:window.location.href,
description:'此FOF由{{user_name}}获取,
消息:“”
});     
});
});
按钮可以是:

<div class="share"> <img src = "{{ STATIC_URL }}images/share_facebook.png" id="share_button1" type='button_count'></div>  
<div class="share"> <img src = "{{ STATIC_URL }}images/share_facebook.png" id="share_button2" type='button_count'></div>  
<div class="share"> <img src = "{{ STATIC_URL }}images/share_facebook.png" id="share_button3" type='button_count'></div>


FB来自哪里=?@mallix请检查此问题,您能提供帮助吗@EgzontinaK链接已断。。我还需要知道如何获得FB对象。我知道这是旧的,但仅供参考-而且,这个解决方案不再有效。Facebook已经否决了这些功能。请参见底部的“弃用参数”: