23
SPSNYC 2013 Intro to SharePoint’s Social APIs SHAREPOINT SATURDAY NYC– JULY 27, 2013 MIKE ORYSZAK BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

Embed Size (px)

DESCRIPTION

Developer's introduction to the SharePoint Social APIs including the client side object models, REST and oData, and Server object model.

Citation preview

Page 1: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013

Intro to SharePoint’s Social APIsSHAREPOINT SATURDAY NYC– JULY 27, 2013

MIKE ORYSZAK

BLOG: WWW.MIKEORYSZAK.COMTWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 2: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 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

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

2

Page 3: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 3 | SharePoint Saturday New York City 2013

Housekeeping Please remember to turn in your filled out bingo

cards and event evaluations for prizes. SharePint is sponsored by Slalom at Whiskey

Trader (Between 55th and 56th on 6th Avenue). Follow SharePoint Saturday New York City on

Twitter @spsnyc and hashtag #spsnyc

Page 4: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

Thanks to Our Sponsors!

Page 5: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 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

5

Page 6: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

6SPSNYC 2013

Feature OverviewINTRO TO SHAREPOINT’S SOCIAL APIS

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 7: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 7

Feature OverviewSocial Platform

MySite Host: Centralized Site Collection that supportsNewsfeed – Functions as a social hubAbout Me (Profile) Page – Displays information about the person, their expertise, and social activities

Personal Site: Individual Site Collections that containDocuments (personal and shared)BlogTasksApps

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

Page 8: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 8

Feature OverviewSocial ContentSocial Content

ConversationsTags/hashtagsNotesRatings

Version Differences:In 2010 Newsfeed was pretty light; could not take action on messagesIn 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

Page 9: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

9SPSNYC 2013

API OptionsINTRO TO SHAREPOINT’S SOCIAL APIS

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 10: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 10

Social API OptionsMultiple 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 JavaScriptRest and ODataServer Object modelSoap based Web Services

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 11: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 11

Social API OptionsClient Object Model – Managed CodeThis 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.UserProfilesContains objects for interacting with user profiles and attributes

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 12: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 12

Social API OptionsClient Object Model – Managed CodeDiffers from Server OM in that it requires a Client Context and cannot hold an open connection

Quick Example – Load a User Profilestring spUrl = "http://serverName/"; string user = "domainName\\userName";

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

Page 13: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 13

Social API OptionsClient Object Model – JavaScriptGreat 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

Page 14: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 14

Social API OptionsClient Object Model – JavaScriptSimilar 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 = "domainName\\userName"; 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

Page 15: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 15

Social API OptionsREST and ODataThe data is also available directly via the underlying REST services

These can be accessed from any language

REST EndpointsSocial 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.PeopleManagerRead or write user profile information

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 16: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 16

Social API OptionsServer Object ModelFull 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 dataMicrosoft.Office.Server.SocialData: Core objects for interacting with social data such as tags and ratingsMicrosoft.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

Page 17: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 17

Social API OptionsServer Object ModelOne 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 ProfileSPContext context = SPContext.Current;string accountname = "domainName\\userName"; 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

Page 18: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 18

Social API OptionsSoap Based Web Service APIThese 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

Page 19: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

19SPSNYC 2013

ExamplesINTRO TO SHAREPOINT’S SOCIAL APIS

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 20: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

20SPSNYC 2013

Examples

Demonstration.NET Client OM

Read Profile PropertiesAccess Tags/Note Data

Server OM Read Profile Properties

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 21: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

22SPSNYC 2013

CloseoutINTRO TO SHAREPOINT’S SOCIAL APIS

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 22: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

23SPSNYC 2013

Questions?

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK

Page 23: Intro to SharePoint's Social APIs - SharePoint Sat NYC 2013

SPSNYC 2013 24

ResourcesMSDN API References

Choose the right APIhttp://msdn.microsoft.com/en-us/library/jj164060.aspx

Server Object Modelhttp://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.aspxhttp://

msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.social.aspx

My Social Blog Postshttp://mikeoryszak.com/tag/social/

Sample Projectshttp://mikeoryszak.com/wp-content/uploads/20

13/06/SPBlueprints.SocialExamples.ClientOM.zip

http://mikeoryszak.com/wp-content/uploads/2013/06/SPBlueprints.SocialExamples.ServerOM.zip

http://mikeoryszak.com/wp-content/uploads/2013/06/SPBlueprints.OutofOfficeDelegation-2013.zip

LinkPad http://www.linqpad.net/

BLOG: WWW.MIKEORYSZAK.COM TWITTER: @NEXT_CONNECT LINKEDIN: HTTP://WWW.LINKEDIN.COM/IN/MICHAELORYSZAK