2

我有一个客户强烈喜欢 Facebook 的“分享”按钮而不是“喜欢”按钮的项目。我需要稍微修改“like”以说服他们使用它。我很清楚“共享”按钮已被弃用(并因此而出现问题),但他们一直非常坚持。

除了按钮的措辞之外,他们似乎更喜欢的是“共享”按钮弹出窗口,它还允许用户通过单击它来更改默认文本(由 Facebook 的开放图形标签提供,即 og:description 等) .

如果“喜欢”按钮的功能更像“分享”,也许可以让他们使用“喜欢”按钮。是否有可能以某种方式让“喜欢”按钮弹出对话框(当您单击按钮并具有 og:title、og:image、og:description 等标签时出现)出现在弹出窗口中?最好能够让用户通过单击它来更改该文本,因为“共享”弹出窗口允许?

他们也想要计数器,否则我只会在下面使用带有锚标记的 css。

我尝试了以下方法,但“喜欢”按钮没有运气。谷歌将被我的网站和它自己的 og 标签所取代:

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">

    <head></head>

    <body>

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

          function share() {
             FB.ui({
                 method: 'stream.share',
                 u: 'www.google.com',
              });
          };

          (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/all.js#xfbml=1";
              fjs.parentNode.insertBefore(js, fjs);
          }(document, 'script', 'facebook-jssdk'));

        </script>

        <fb:like id="fbLike" href="www.google.com" onclick="share();" send="false" layout="box_count" show_faces="false" ></fb:like>

        <a href="#/" onclick="share();">Can I get the like button to work like this?</a>

    </body>
    </html>
4

2 回答 2

1

为什么不使用提要对话框在用户墙上分享。有没有什么特别的理由不使用它,我错过了?

调用提要对话框的代码将是这样的:

     function share() {
        FB.ui({
        method: ‘feed’,
        link: ‘link of where the user should land when he click on post goes here’,
        picture: ‘picture url goes here’,
        name: ‘Name goes here’,
        caption: ‘Caption goes here e.g www.google.com’,
        description: ‘description goes here’}, 
        function (response) {
                      if (!response || response.error) {
                    //When posting fails
                      } else {
                    //When posting succeeds
          }
    );
}

您可以在此处找到更多详细信息:https ://developers.facebook.com/docs/reference/dialogs/feed/

于 2012-10-23T07:06:05.480 回答
0

Well, it seems that nobody has a workaround. I guess if somebody finds my anchor example useful to create a custom share button (even though it's deprecated - seriously, unless you're in my boat, help yourself out and just use like), at least my problem's helped somebody out. I've found that adding:

    style="overflow:hidden"

to the fb:like tag, and then adding the following code to the beginning of the script block (just before the share function):

    window.fbAsyncInit = function() {
        FB.init({
            appId: ''
        });
        FB.Event.subscribe('edge.create', function(response) {
            share();
        });
    };

will hide the like dialog, and use the share popup when the user clicks the like button (the edge.create listens for the user like action). The problem, though, is that the user will then have two posts on the user's wall - one for the like action, and another for the share. With both posting, as expected, the same open graph tag title, image, and description information, only with one post saying they 'liked' and the other saying they 'shared'. But I'd need to prevent the 'like' one. And the counter will, of course, increment by 2. Close, but not quite good enough.

Any way to just make the like dialog box appear in a popup window?

于 2012-10-22T21:14:32.887 回答