Spsatl2013 Introduction to the SharePoint's Social APIs
1. SPSATL 2013
Intro to SharePoint’s
Social APIs
SHAREPOINT SATURDAY ATLANTA – JUNE 8, 2013
MIKE ORYSZAK
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
2. SPSATL 2013
About Me
Senior SharePoint Solution Architect w/ B&R Solutions
Microsoft SharePoint Server MVP
Leader for Triangle SharePoint User Group (TriSPUG)
Dev and Architect with MS stack since 1996
Working with SharePoint since 2002
Raleigh-Durham, NC
Scan the QR code for a
chance to win a prize!
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
2
7. SPSATL 2013
Session
Overview
Feature Overview
API Options
Examples
Closeout
Target Audience:
Developers looking to leverage or
extend SharePoint’s Social Features.
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
7
8. SPSATL 2013
Feature Overview
INTRO TO SHAREPOINT’S SOCIAL APIS
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
8
9. SPSATL 2013SPSATL 2013
Feature Overview
Social Platform
MySite Host: Centralized Site Collection that supports
Newsfeed – Functions as a social hub
About Me (Profile) Page – Displays information about the person, their expertise, and social activities
Personal Site: Individual Site Collections that contain
Documents (personal and shared)
Blog
Tasks
Apps
Version Differences:
In 2010
Newsfeed was pretty light; could not take action on messages
About Me page less focused on social, more focused on organization
In 2013
Newsfeed supports replies, likes, mentioning people.
Newsfeed can function more like a social hub for things you are following. Ex. People, Documents, Sites, Tags
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
9
10. SPSATL 2013SPSATL 2013
Feature Overview
Social Content
Social Content
Conversations
Tags/hashtags
Notes
Ratings
Version Differences:
In 2010 Newsfeed was pretty light; could not take action on messages
In 2013
Newsfeed extended to support conversations including replies, likes, mentioning people.
Newsfeed can function more like a social hub for things you are following. Ex. People, Documents, Sites, Tags
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
10
11. SPSATL 2013
API Options
INTRO TO SHAREPOINT’S SOCIAL APIS
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
11
12. SPSATL 2013SPSATL 2013
Social API Options
Multiple Options for interacting with social data and features.
Ranked in recommended order of preference:
Client Object Model for managed code (.NET, Silverlight, Mobile)
Client Object Model for JavaScript
Rest and OData
Server Object model
Soap based Web Services
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
12
13. SPSATL 2013SPSATL 2013
Social API Options
Client Object Model – Managed
Code
This is Microsoft’s recommended approach
Provides a wrapper for the REST based services
Used within the new SharePoint Apps or non-SharePoint Apps not running for the server
Namespaces:
Microsoft.SharePoint.Client.Social
Core objects for interacting with social feeds, posts, and following data
Microsoft.SharePoint.Client.UserProfiles
Contains objects for interacting with user profiles and attributes
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
13
14. SPSATL 2013SPSATL 2013
Social API Options
Client Object Model – Managed
Code
Differs from Server OM in that it requires a Client Context and cannot hold an open connection
Quick Example – Load a User Profile
string spUrl = "http://serverName/";
string user = "domainNameuserName";
ClientContext context = new ClientContext(spUrl);
PeopleManager peopleManager = new PeopleManager(context);
PersonProperties props = peopleManager.GetPropertiesFor(user);
clientContext.Load(props, p => p.AccountName, p => p.UserProfileProperties);
clientContext.ExecuteQuery();
string email = props.UserProfileProperties["Email"].ToString();
string department = props.UserProfileProperties["Department"].ToString();
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
14
15. SPSATL 2013SPSATL 2013
Social API Options
Client Object Model – JavaScript
Great for client-side customizations inside of SharePoint or externally
This is the equivalent of what was previously accomplished with SPServices
Namespaces:
SP.Sharing (/_layouts/sp.js)
Contains objects for interacting with the sharing features
SP.Social (/_layouts/sp.userprofiles.js)
Core objects for interacting with social feeds, posts, and following data
SP.UserProfiles (/_layouts/sp.userprofiles.js)
Contains objects for interacting with user profiles and attributes
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
15
16. SPSATL 2013SPSATL 2013
Social API Options
Client Object Model – JavaScript
Similar to Client OM in that it requires a Client Context and cannot hold an open connection
Quick Example – Load a User Profile
var spUrl = "http://serverName/";
var acctName = "domainNameuserName";
var context = new SP.ClientContext(spUrl);
var peopleManager = new SP.UserProfiles.PeopleManager(context);
var profilePropertyNames = ["Email", "Department", “Title”];
var userProperties = new
SP.UserProfiles.UserProfilePropertiesForUser(context, acctName, profilePropertyNames);
var props = peopleManager. getUserProfilePropertiesFor(userProperties);
context.load(userProperties);
context.executeQueryAsync(
function () { "Email:" + alert(props[0] + " | Department: " + props[1] + " | Title: " +
props[2]); }, function () { alert("Error Loading User Profile") });
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
16
17. SPSATL 2013SPSATL 2013
Social API Options
REST and OData
The data is also available directly via the underlying REST services
These can be accessed from any language
REST Endpoints
Social Feed: http://<mySiteUri>/_api/social.feed
Read or write to a user’s social feed
Social Following: http://<mySiteUri>/_api/social.following
Read or write following information
People Manager: http://<siteUri>/_api/SP.UserProfiles.PeopleManager
Read or write user profile information
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
17
18. SPSATL 2013SPSATL 2013
Social API Options
Server Object Model
Full featured, and traditional developers are most comfortable here
Requires deployment through full trust, server solutions
Social Namespaces:
Microsoft.Office.Server.Social: Core objects for interacting with social feeds, posts, and following data
Microsoft.Office.Server.SocialData: Core objects for interacting with social data such as tags and ratings
Microsoft.Office.Server.UserProfiles: Contains objects for interacting with user profiles and attributes
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
18
19. SPSATL 2013SPSATL 2013
Social API Options
Server Object Model
One difference with the Server OM is that it requires a Service Context to connect to the
appropriate User Profile Service Application.
Quick Example – Load a User Profile
SPContext context = SPContext.Current;
string accountname = "domainNameuserName";
SPServiceContext svcContext = SPServiceContext.GetContext(context.Site);
UserProfileManager profileManager = new UserProfileManager(svcContext);
UserProfile profile = profileManager.GetUserProfile(accountname);
string email = profile["Email"].Value;
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
19
20. SPSATL 2013SPSATL 2013
Social API Options
Soap Based Web Service API
These have officially been deprecated with SharePoint 2013.
Previously released services still available, but no new investment.
Migrate to another API
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
20
21. SPSATL 2013
Examples
INTRO TO SHAREPOINT’S SOCIAL APIS
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
21
22. SPSATL 2013
Examples
Demonstration
.NET Client OM
Read Profile Properties
Access Tags/Note Data
Server OM
Read Profile Properties
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
22
23. SPSATL 2013
Closeout
INTRO TO SHAREPOINT’S SOCIAL APIS
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
24
25. SPSATL 2013SPSATL 2013
Resources
MSDN API References
Choose the right API
http://msdn.microsoft.com/en-us/library/jj164060.aspx
Server Object Model
http://msdn.microsoft.com/en-us/library/jj193040.aspx
Client Object Model
.Net Client: http://msdn.microsoft.com/en-
us/library/jj193046.aspx
Javascript: http://msdn.microsoft.com/en-
us/library/jj193045.aspx
http://msdn.microsoft.com/en-
us/library/microsoft.sharepoint.client.social.aspx
My Social Blog Posts
http://mikeoryszak.com/tag/social/
Sample Projects
A
B
C
LinkPad
http://www.linqpad.net/
BLOG: WWW.MIKEORYSZAK.COM
TWITTER: @NEXT_CONNECT
LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK
26
26. @SPS_ATL #SPSATL
speaker sponsor
Session Prizes
1 4 $25 gift cards
2 4 $25 gift cards
3 4 $25 gift cards
4 4 $25 gift cards
5 4 $25 gift cards
Notas do Editor
Social Namespace: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.social.aspxUserProfiles Namespace: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.userprofiles.aspx
Social Namespace: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.social.aspxUserProfiles Namespace: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.userprofiles.aspx
http://msdn.microsoft.com/en-us/library/jj193058.aspx#SPNETServerlanding_SocialSocial Classes: http://msdn.microsoft.com/en-us/library/jj193040.aspxWork with Social Feeds in SharePoint 2013: http://msdn.microsoft.com/en-us/library/jj163237.aspx
http://msdn.microsoft.com/en-us/library/jj193058.aspx#SPNETServerlanding_SocialSocial Classes: http://msdn.microsoft.com/en-us/library/jj193040.aspxWork with Social Feeds in SharePoint 2013: http://msdn.microsoft.com/en-us/library/jj163237.aspx