Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Share Button Problems

Tags:

facebook

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.

like image 546
ian Avatar asked Nov 21 '09 20:11

ian


3 Answers

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

like image 78
leepowers Avatar answered Nov 01 '22 00:11

leepowers


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>
like image 41
dorje Avatar answered Oct 31 '22 23:10

dorje


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/

like image 21
Zeke Avatar answered Nov 01 '22 00:11

Zeke