简体   繁体   中英

User wants to post link to their facebook wall

Our early users want to post links to their artifacts onto their facebook wall. Not something we put in the beta version.

This site lets users post photos and descriptions (artifacts from antiquity) and instead of referring people to our site they prefer posting a link to their 2nd century bc ornaments' photos onto their facebook wall.

I will add a button 'FB' on our site -- they click the button and (somehow) a 'log in to facebook' window appears so they can immediately put the link on our site of their antique onto their wall.

I have studied this on SO and read posts on 'share,' 'like,' the FB sdk docs, the 'graph api', but it all seems like not what I need to do, which is simple -- add a FB button on our site that when clicked lets them log on to their Facebook account so they can put the link on their wall.

Surely this is a solved problem -- or is it?

You do want to use the FB API's Share button.

https://developers.facebook.com/docs/share/

Specifically, you'll want a button like:

<a name="fb_share"
    url="<?php echo "//" + $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?>"
></a> 
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

[Edit] As discussed in the comments, Share is deprecated. Here is the like code:

<div id="fb-root"></div>
<script>(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&appId=<?php echo $APP_ID; ?>";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like"
    data-href="<?php echo "//" + $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?>"
    data-send="true" data-width="450" data-show-faces="true"></div>

And on closer examination, this is the code I'm currently using on my content network; I'd forgotten this was the new version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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