Skip to content

Social Share Integration

Use PHP to create code that will populate the share data dynamically as an include on each page.

i.e. Get title from <title> description from <meta name=”description” content=”Come to X-site today! Try your skills with our ABC Product, and enter to win fun XYZ stuff!”>

Or write in manually, or leave blank for users to fill before your link and/or  tags.

Reference: https://developers.facebook.com/docs/plugins/share-button

Code Needed:

<html>
<head>
	<title>Your Website Title</title>
    <!-- You can use Open Graph tags to customize link previews.
    Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
	<meta property="og:url"           content="http://www.your-domain.com/your-page.html" />
	<meta property="og:type"          content="website" />
	<meta property="og:title"         content="Your Website Title" />
	<meta property="og:description"   content="Your description" />
	<meta property="og:image"         content="http://www.your-domain.com/path/image.jpg" />
</head>
<body>

	<!-- Load Facebook SDK for JavaScript -->
	
id="fb-root">
<!-- Your share button code -->
class="fb-share-button" data-href="http://www.your-domain.com/your-page.html" data-layout="button_count">
</body> </html>

Twitter Share with custom text

Reference: https://dev.twitter.com/web/tweet-button

Code Needed:

<a class="twitter-share-button"
href="https://twitter.com/intent/tweet?
text=Create Share Buttons without widgets @daniioliver" 
data-size="large">
Tweet</a>

These code snippets are  all you need with a static or dynamically filled text property.
Link target _blank so as to not redirect from the site and of course add tracking tags.

Linkedin Share https://developer.linkedin.com/plugins

Advertisements
%d bloggers like this: