Here is an example of how to retrieve social ratings
Using Object model -
string GetRatingForThisURL = “http://MySharePoint/Pages/NewWebPart.aspx”;
Uri myUri = new Uri(GetRatingForThisURL);
using (SPSite site = new SPSite(“http:/SharePointSite”))
{
SPServiceContext context = SPServiceContext.GetContext(site);
SocialRatingManager mySocialRatingManager = new SocialRatingManager(context);
SocialRating aRating = mySocialRatingManager.GetRating(myUri);
Console.WriteLine(aRating.Url + “: ” + aRating.Rating);
}
Using WebService -
string GetRatingForThisURL = “http://MySharePoint/Pages/NewWebPart.aspx”;
ServiceReference1.SocialDataService mySocialDataService = new ServiceReference1.SocialDataService();
mySocialDataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
mySocialDataService.Url = “http://MySharePoint/_vti_bin/socialdataservice.asmx”;
SocialRatingDetail details = mySocialDataService.GetRatingOnUrl(GetRatingForThisURL);
Console.Write(“The rating for ” + GetRatingForThisURL + ” is ” + details.Rating.ToString());
Console.Read();
No comments:
Post a Comment