【问题标题】:Trying to share a link to facebook only shares the main url试图分享到 facebook 的链接只分享主 url
【发布时间】:2012-12-03 14:40:19
【问题描述】:

我是 twitter、facebook 等 api 和 javascripts 的新手。

其他人可能会问类似的问题,但请检查我的问题,我想这个问题不是重复的。

我正在尝试将网址分享到 facebook。这是我的代码

<?php $link="www.google.com"> 
    <script>
        function fbs_click() 
        {
        u=location.href;
        t=document.title;
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
        }
        </script>
        <style>
        html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px;  background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; } html .fb_share_button:hover { color:#fff; url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; text-decoration:none; }
        </style> 
        <a rel="nofollow" href="http://www.facebook.com/share.php?u=<?php  echo $link;?>" 
        class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-align:center;"></a>
        </div>

但不是共享www.google.com,而是显示主网址,例如www.mysite.com/facebookshare.php我哪里出错了。

我也尝试了一个简单的锚标记方法来分享,但它扰乱了我的整个 css。 示例

<a href = "http://www.facebook.com/sharer/sharer.php?u= <?php echo $link;?>">
                    <img src = "http://www.mysite.com/FB_2.png"></a>

请帮我获取我希望分享到 facebook 的确切网址 (www.google.com)。

谢谢

【问题讨论】:

    标签: php facebook share facebook-sharer


    【解决方案1】:

    https://stackoverflow.com/questions/10566503/facebook-share-sharer-php-x-facebook-debugger?rq=1 fb 不再支持 fb 的共享器部分,您必须使用 javascript api https://developers.facebook.com/docs/reference/dialogs/feed/ 的提要对话框部分 还要确保您的 og 元标记包含正确的信息 http://ogp.me/ 这可能是您的问题

    【讨论】:

      猜你喜欢
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多