简体   繁体   English

试图分享到Facebook的链接只分享主要网址

[英]Trying to share a link to facebook only shares the main url

I am new to twitter,facebook etc api's and javascripts. 我是twitter,facebook等api和javascripts的新手。

A similar question might be asked by some one else but please check my question, I guess this question is not a duplicate one. 其他人可能会问一个类似的问题,但请检查我的问题,我想这个问题不是重复的问题。

I am trying to share a url to facebook . 我正在尝试与Facebook分享网址 Here is my code 这是我的代码

<?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>

But instead of sharing www.google.com it shows main url such as www.mysite.com/facebookshare.php where am i going wrong. 但不是分享www.google.com而是显示主要网址,例如www.mysite.com/facebookshare.php ,我哪里出错了。

I also tried a simple anchor tag method to share but it disturbs my entire css. 我也试过一个简单的锚标记方法来分享,但它扰乱了我的整个CSS。 exmaple 〔实施例

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

Please help me to get the exact url i wish (www.google.com) to be shared to facebook. 请帮助我将我想要的确切网址(www.google.com)分享到Facebook。

Thank you 谢谢

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM