如何在我的网站上添加 Facebook 分享按钮? [英] How to add facebook share button on my website?

查看:34
本文介绍了如何在我的网站上添加 Facebook 分享按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码可以工作,但不起作用.如果这对您有所帮助,那就太好了.

I have this code that suppose to work, but doesn't work. If this helps you in anyway that would be great.

<script src='http://connect.facebook.net/en_US/all.js'></script>
    <p><a onclick='postToFeed(); return false;'><img src="images/fb.png" /></a></p>
    <p id='msg'></p>

    <script> 
      FB.init({appId: "338334836292077", status: true, cookie: 

true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          redirect_uri:'https://www.facebook.com/cryswashington?fref=ts',
          link:'https://developers.facebook.com/docs/reference/dialogs/',
          picture: 'http://fbrell.com/f8.jpg',
          name: 'Facebook Dialogs',
          caption: 'Reference Documentation',
          description: 'Using Dialogs to interact with users.'
        };

        function callback(response) {

        document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

        FB.ui(obj, callback);
      }

    </script>

我想在我的网站上添加 facebook 分享按钮,这应该只是将我网站的内容张贴在墙上.谁想分享.

I want to add facebook share button on my website, that should just post my website's content on the wall. who want to share it.

我研究了很多,但没有得到任何东西.请在这方面帮助我.

I have researched a lot but did not get anything. Pleas help me in this.

提前致谢.

推荐答案

您不需要所有这些代码.您只需要以下几行:

You don't need all that code. All you need are the following lines:

<a href="https://www.facebook.com/sharer/sharer.php?u=example.org" target="_blank">
  Share on Facebook
</a>

文档可以在 https://developers.facebook.com/找到文档/参考/插件/共享链接/

这篇关于如何在我的网站上添加 Facebook 分享按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆