Nowadays any social network offers wide range of information sharing facilities including easy sharing links from 3rd party websites. Social network offers to install small button onto your website and single click will put link to your content to Facebook, Twitter - whatever feed and your resource is popular.
*
This is easy and useful both for the user and the website owner. A user can share interesting content quickly, site owner can use all the power social networking to deliver content and get profit or just additional traffic and interest to the resource.
The Task
What we want to get is a get a range of the most popular social networks connected to our website. Let’s say 32x32 pixel buttons for Facebook, Twitter and Digg, which will be populated under the article, image or video on your website.
Simplest Way to Implement
Creating a button is very easy and shouldn’t take more than 10 minutes of your time – just find the URL for a specific network (e.g. http://digg.com/submit?phase=2&url=%url%&title=%title% for Digg), fill it in with your URL, title and it’s all done! However if you have many controls – you’ll have to repeat this code for every separate link which is not as easy.
Simpler Way to Extend
All the URL’s have 2 parameters only - title and URL, all use GET requests, so we can standardize them like http://digg.com/submit?phase=2&url={0}&title={1} and do the simplest string.Format() to create proper request. So the steps are:
1. Create a common base class for all controls like SocialControl, which will accept the title and address of the promoted resource.
2. Create several controls that will be inherited from SocialControl and will implement request formatting and provide visual appearance.
3. Host control which will operate with SocialControl’s and will allow you to add and remove icons dynamically.
Result
We have performed these steps and have social networking now available on the Magnetism Help Portal.
And the Magnetism Website
*Image 1 from: http://orangecopper.com/blog/list-of-all-top-social-networking-websites-as-on-2010