9
votes

I am trying to create a share button for links using the Facebook share button:

http://www.facebook.com/facebook-widgets/share.php http://wiki.developers.facebook.com/index.php/Facebook_Share

However when I try to use the t value in my URL's they don't work.

I even tried using the example on the API page:

http://www.facebook.com/sharer.php?u=http%3A%2F%2Fdevelopers.facebook.com%2F&t=Facebook%20Developers

And it doesn't work... It sets the title as developers.facebook.com not Facebook Developers as specified by the URL

Anyone know how I can make this work correctly?

I want my share links to come up as... 'Title Of what I am sharing' and then... the url directly to that item.

5

5 Answers

5
votes

The Facebook share link dynamically fetches the title and images from the page/website to share. The title specified in the link is only used while Facebook loads the page details. Check this link out:

http://www.facebook.com/sharer.php?u=http://www.rackspace.com&t=SOME%20TITLE

5
votes

My solution to the title parameter is:

as url, add to the page url a variable (lik real_title):

http://www.facebook.com/sharer.php?u=http://mydomain.net/mypage?real_title=MyTitle

Then, in the index.php page:

< title> 
    <?php if (isset ($_GET['real_title'])) 
             print ($_GET['real_title']);
          else 
             print ("Default page title"); ?>
< /title>
1
votes

Facebook crawls the given URL in search of Open Graph meta tags. It gives precedence to the contents of those tags, if they're present. Here's a sample of what the Open Graph tags look like:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>The Rock (1996)</title>
    <meta property="og:title" content="The Rock"/>
    <meta property="og:type" content="movie"/>
    <meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
    <meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
    <meta property="og:site_name" content="IMDb"/>
    <meta property="fb:admins" content="USER_ID"/>
    <meta property="og:description"
          content="A group of U.S. Marines, under command of
                   a renegade general, take over Alcatraz and
                   threaten San Francisco Bay with biological
                   weapons."/>
    ...
  </head>
  ...
</html>

More info at http://developers.facebook.com/docs/opengraph/

0
votes

I also met this problem, but i have found the problem because i didn't put facebook code in that file http://bannedadsense.com/banned-adsense-list/isbanned, i was very stupid with it and lost time to fix, but now i'm lucky, i have just fixed done now, simple only copy fb code to all pages you want to use fb share like button.

<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/sdk.js#xfbml=1&version=v2.8&appId=put_number_id_here";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>