Reputation: 1353
I am new to twitter,facebook etc api's and 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. 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.
I also tried a simple anchor tag method to share but it disturbs my entire 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.
Thank you
Upvotes: 0
Views: 3006
Reputation: 635
https://stackoverflow.com/questions/10566503/facebook-share-sharer-php-x-facebook-debugger?rq=1 the sharer part of fb is no longer supported by fb you have to use the feed dialog part of javascript api https://developers.facebook.com/docs/reference/dialogs/feed/ also make sure your og meta tags contain the correct information http://ogp.me/ that could be your problem
Upvotes: 2