Add Social Media Share Links to Your Website
I finally gave in and put social share links on this website at the bottom of each article. I've had them for authoring articles on the back-end for awhile, but decided it was time for users to have the ability. If the Internet were a football locker room, this website is one step closer to being a jock.
I started to discover that all of the services had a simple URL with query string parameters to initiate sharing. This doesn't allow the services to directly track visitors to this website, of course, until they click on the link to share. Also, this allows me to have complete control of what's rendered and how - even if it is just some simple images with some fancy CSS effects.
To do this there are just a couple variables, some of which are not used by all of the services.
|USERNAME||Applicable service username|
|URL||Full URL to the article|
|SUMMARY||A summary description of the article|
|IMAGEURL||A URL to an image for the article|
These are going into a query string, so their values must be safe for that purpose and this usually requires encoding. For example, in PHP you can use the rawurlencode() function on each of the values.
Here are the URLs I've managed to come up with. Some of them are not using all of the available variables, but they seem to work just fine.
Voilà, you've got some live share buttons. Not too flashy, not too plain, just right.