问题
I have a daily deal aggregator site and i can't get the Facebook share to work properly. There are lots of deals on each page and each one has it's own FB share so they can post it on their wall, friends walls etc.
here is the site so you can try the share: http://bit.ly/xFGzj5
Here is the code Im using now:
<!-- Each Deal has this button that links to FB -->
<a href="http://www.facebook.com/share.php?u=<?php echo urlencode($shareurl); ?>" onclick="return fbs_click('<?php echo urlencode($shareurl); ?>','<?php echo $title; ?>')" target="_blank"><img src="../../images/fb.png" border="0" alt="Share On Facebook" class="smicon" /></a>
<!--And here is the JS function:-->
<script>
function fbs_click(u,t) {
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>
With this method, right now the title is not working properly, and sometimes an image shows up, sometimes it doesn't. When an image does show there are about 200 thumbnails to choose from (depending on how many deals are on the page) so the user has to cycle through it until they find the right one.
Ideally, I want the url/title working properly (obviously) and have the image go to that specific deal's image by default when they click the share button. Anyone have any ideas on how to make this work???
回答1:
why are you taking this approach? i recommend using either the social widgets or the javascript sdk fb provides.
for example, with the js sdk you can do this: https://developers.facebook.com/docs/reference/dialogs/send/
as for the social widgets, you can add a like for each item: https://developers.facebook.com/docs/reference/plugins/like/
or send button: https://developers.facebook.com/docs/reference/plugins/send/
回答2:
Just remember to have the JS Function only once on your main page, otherwise it is loaded every time a page loads. That will prevent the images from disappearing. In .NET I added all the FB funcion-scripts in the Site.master page and it works fine.
来源:https://stackoverflow.com/questions/9279759/multiple-facebook-shares-on-one-page