dousheyan0375 2015-08-13 11:20
浏览 29

如何使用php触发我的网站上的另一个按钮fb共享

I know how to add facebook share button on my website to share a content on fb page. However, I would like to know how to trigger this share button when I click on another button on the same page. Here is how I would like it to function:

  1. I have admin backend to approve user's posts before showing it on front-end.

  2. As soon as admin click approve button (runs a jquery function), then this user's post will also be shared on admin fb's page as well.

Here is approve link, to approve post in admin-end:

<td style='padding-left:5px'><a id='$rowi[postid]' class='adminapprovepost' href='#'>Approve</a></td>

Here is the js code:

$(function() {
$(".adminapprovepost").click(function(){
var id = $(this).attr("id");
var proceed = true;
    while(proceed) {
        tag = prompt("You must input at least one keyword for this post");
        if (typeof(tag) == "string") {
            tag = tag.trim()
            if (tag!="") {
                proceed = false;
            }
        }
        if (tag===null) {
            proceed = false;
        }
    }
if(tag!=null)
{
$.ajax({
type: "POST",
url: "/admin/admin-approve-post.php",
data: {id:id,tag:tag},
success: function(){
}
});
$(this).parents(".postrecord").animate({ backgroundColor: "#fbc7c7" }, "fast")
.animate({ opacity: "hide" }, "slow");
}
return false;
});
});

Here is my facebook share code:

<div class="fb-share-button" data-href="https://www.mywebsite.com" data-layout="button_count"></div>

Here is the JS of that fb code:

<div id="fb-root"></div>
<script>(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.js#xfbml=1&version=v2.4&appId=920558657967273"    ;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
  • 写回答

1条回答 默认 最新

  • doufen3091 2015-08-13 11:34
    关注

    As soon as admin click approve button (runs a jquery function)

    In the success of the ajax you can trigger the click:

    success: function(){
       $('.fb-share-button').trigger('click');
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本