One service that I had used a while back was AddThis social bookmarks. I really liked its ease of use, support for a huge range of social networks and bookmarking sites, and most importantly it had great tools for analytics.
You can see this for yourself in the social bar below this post. Check out the links as you hover over the images, they’re constructed exactly as I will show you here.
Finding the Link
The trick here is as simple as tweaking a URL.
This is the most basic option of the API. It sends us to a page in which we can choose where we want to share the link. It’s good if you have a simple “Share This” button, but not if we want different links to specific social networks. Plus, we won’t get that analytics data.
In the above example, just replace
URL with your page’s location.
Now we’ll add a title and user name. For this we add another two URL parameters. Just replace URL, title and user name like before.
And lastly, where we want to specify where we are going to take the user we need to add
forward/SERVICE/ into our link.
The link above will take you straight to Facebook, formatting the data to easily post the page up onto your wall.
A Simple Example
So, for a full implementation of this API we can use a list of hyperlinks like in my social bar, and styled how you like them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<ul> <li> <a href="http://api.addthis.com/oexchange/0.8/forward/twitter/offer?url=http%3A%2F%2Fstevedecoded.com&title=Stephen+McIntyre&username=StephenMcIntyre">Twitter</a> </li> <li> <a href="http://api.addthis.com/oexchange/0.8/forward/facebook/offer?url=http%3A%2F%2Fstevedecoded.com&title=Stephen+McIntyre&username=StephenMcIntyre">Facebook</a> </li> <li> <a href="http://api.addthis.com/oexchange/0.8/forward/digg/offer?url=http%3A%2F%2Fstevedecoded.com&title=Stephen+McIntyre&username=StephenMcIntyre">Digg</a> </li> <li> <a href="http://api.addthis.com/oexchange/0.8/forward/delicious/offer?url=http%3A%2F%2Fstevedecoded.com&title=Stephen+McIntyre&username=StephenMcIntyre">Delicious</a> </li> </ul>
For a full list of service tags to use in the
SERVICE section of the URL, check out the service codes page on the AddThis docs. You can copy the short codes from each row, there’s loads to choose from.
More information on the sharing endpoints can also be found on there, which will help if you’re looking to dig further into the API.
One Last Thing
So as you can see, the links can get pretty long. If you’re inputting these manually, even a copy-paste job can be tedious, especially if you plan to go about dotting them all over your website.
The ideal situation then would be to generate these automatically, which can be done through PHP with some urlencode magic.
Also, if you’re using WordPress, then fetching the link and title is easy with
I’ll be releasing a tool that utilises the AddThis API very soon, and adding some tutorials on here as to how it’s done, including some clever PHP.