How do I customize Facebook's sharer.php
What you are talking about is the preview image and text that Facebook extracts when you share a link. Facebook uses the Open Graph Protocol to get this data.
Essentially, all you'll have to do is place these og:meta
tags on the URL that you want to share -
<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."/>
As you can see there are both an image property and a description. When you make changes to your pages og:meta
tags, you can test these changes using the Facebook Debugger. It will tell you if you have made any mistakes (and how to fix them!)
UPDATE:
This answer is outdated.
Like @jack-marchetti stated in his comment, and @devantoine with the link: https://developers.facebook.com/x/bugs/357750474364812/
Facebook has changed how the sharer.php works, as Ibrahim Faour replies to the bug filed with Facebook.
The sharer will no longer accept custom parameters and facebook will pull the information that is being displayed in the preview the same way that it would appear on facebook as a post, from the url OG meta tags.
Try this (via Javascript in this example):
'http://www.facebook.com/sharer.php?s=100&p[title]='+encodeURIComponent('this is a title') + '&p[summary]=' + encodeURIComponent('description here') + '&p[url]=' + encodeURIComponent('http://www.nufc.com') + '&p[images][0]=' + encodeURIComponent('http://www.somedomain.com/image.jpg')
I tried this quickly without the image part and the sharer.php window appears pre-populated, so it looks like a solution.
I found this via this SO article:
Want custom title / image / description in facebook share link from a flash app
and this link contained in an answer from Lelis718:
http://www.daddydesign.com/wordpress/how-to-create-a-custom-facebook-share-button-for-your-iframe-tab/
so all credit to Lelis718 for this answer.
[EDIT 3rd May 2013] - seems like the original URL i had here no longer works for me without also including "s=100" in the query string - no idea why but have updated accordingly
It appears the following answer no longer works, and Facebook no longer accepts parameters on the Feed Dialog links
You can use the Feed Dialog via URL to emulate the behavior of Sharer.php, but it's a little more complicated. You need a Facebook App setup with the Base URL of the URL you plan to share configured. Then you can do the following:
1) Create a link like:
http://www.facebook.com/dialog/feed?app_id=[FACEBOOK_APP_ID]' +
'&link=[FULLY_QUALIFIED_LINK_TO_SHARE_CONTENT]' +
'&picture=[LINK_TO_IMAGE]' +
'&name=' + encodeURIComponent('[CONTENT_TITLE]') +
'&caption=' + encodeURIComponent('[CONTENT_CAPTION]) +
'&description=' + encodeURIComponent('[CONTENT_DESCRIPTION]') +
'&redirect_uri=' + FBVars.baseURL + '[URL_TO_REDIRECT_TO_AFTER_SHARE]' +
'&display=popup';
(obviously replace the [CONTENT] with the appropriate content. Documentation here: https://developers.facebook.com/docs/reference/dialogs/feed)
2) Open that link in a popup window with JavaScript on click of the share link
3) I like to create file (i.e. popupclose.html) to redirect users back to when they finish sharing, this file will contain <script>window.close();</script>
to close the popup window
The only downside of using the Feed Dialog (besides setup) is that, if you manage Pages as well, you don't have the ability to choose to share via a Page, only a regular user account can share. And it can give you some really cryptic error messages, most of them are related to the setup of your Facebook app or problems with either the content or URL you are sharing.
Sharer.php no longer allows you to customize. The page you share will be scraped for OG Tags and that data will be shared.
To properly customize, use FB.UI
which comes with the JS-SDK.