Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I customize Facebook's sharer.php

Tags:

facebook

http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.google.com

How can I customize the text and image. It looks like Facebook pulled the docs.

like image 675
Aakil Fernandes Avatar asked Sep 22 '12 19:09

Aakil Fernandes


People also ask

How do I customize my share button on Facebook?

Head over to Meta's documentation and use their button configurator to get the code for a Like and Share Button, or a Share Button. Once you select the options for your custom button, click the Get Code button and a new dialog box will appear with two different scripts.

How do I use Facebook sharer?

To share a post you see on your Feed: Below a post, tap Share in the bottom right. To share to a friend's timeline, tap Feed below your name, then select On a friend's timeline. Type your friend's name, then tap Share Now.


1 Answers

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!)

like image 86
Lix Avatar answered Oct 21 '22 16:10

Lix