In this article you will be seeing how to get all the Social Tags for the specified URL in SharePoint 2010 using the object model. A Social Tag can be created for any specified URL with a valid term using SocialTagManager object. SocialTagManager object contains methods and properties that are used to manipulate social tag data. Here we will be seeing how to get all the social tags for the specified URL in SharePoint 2010 using the SharePoint Object Model. View all the social tags for the specified URL through Central Administration:
Programmatically get all the social tags for the specified URL: Steps Involved:
public class Program { public static void Main(string[] args) {
//// Uri - required to get all the social tags for the specified uri Uri uri = new Uri("https://servername.com/finance/Finance/"); using (SPSite site = new SPSite("https://servername.com/finance/Finance/")) { //// Get the context of the service application SPServiceContext context = SPServiceContext.GetContext(site);
//// SocialTagManager - Contains methods and properties used to manipulate social tag data SocialTagManager socialTagManager = new SocialTagManager(context);
//// GetTags(Uri) method is used to retrieve an array of SocialTag objects that are owned by the current user and that contain the specified URL. SocialTag[] tags = socialTagManager.GetTags(uri); Console.WriteLine("Tags for the URL: " + uri.AbsoluteUri); foreach (SocialTag tag in tags)| { Console.WriteLine("###############################################"); Console.WriteLine(" Tag Name : " + tag.Term.Name); Console.WriteLine(" URL : " + tag.Url.AbsoluteUri); Console.WriteLine(" Title : " + tag.Title); Console.WriteLine(" Owner : " + tag.Owner.DisplayName); } Console.ReadLine(); } } } }
In the solution explorer, right click on the solution and click on Build.
Hit F5.
Summary: Thus in this article you have seen how to get all the social tags for the specified URL in SharePoint 2010 using object model.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: