SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Social Apps with the Force.com
Toolkit for Facebook
Pat Patterson, salesforce.com, Principal Developer Evangelist
@metadaddy
Safe Harbor
 Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

 This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if
 any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-
 looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of
 product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of
 management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments
 and customer contracts or use of our services.

 The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our
 service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth,
 interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated
 with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain,
 and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling
 non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the
 financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This
 documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

 Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may
 not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently
 available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Pat Patterson
Principal Developer Evangelist
@metadaddy
Objectives

 Understand the Facebook Graph API
 Be able to use the Force.com Toolkit for Facebook in an app
 Understand how users can use their Facebook identity to login
 to Salesforce
Agenda

 The Facebook Graph API
 The Force.com Toolkit for Facebook
 Social Sign-On with Authentication Providers
 Create a social application on Force.com
   Login from Facebook
   Share with friends
   Post to timeline
The Facebook Graph API

       https://developers.facebook.com/docs/reference/api/
Accessing Social Graph Objects

 Every social graph object has a unique ID
   https://graph.facebook.com/ID
 For example, ‘Facebook Platform’ has ID 19292868552
   GET https://graph.facebook.com/19292868552
Relationships – Edges on the Graph

 Friends, feed (wall/timeline), likes, photos, videos, etc
 Graph API terminology: connections
   https://graph.facebook.com/ID/CONNECTION_TYPE
 For example, my friends
   Special ID - me
   GET https://graph.facebook.com/me/friends
Graph API Authorization

 OAuth 2.0
   Redirect to Facebook; user authenticates (if necessary) and gives
    permission for app to access the Graph API
   App receives access token representing the user’s permission to
    access their social graph
   App sends access token with Graph API calls as a query parameter
         https://graph.facebook.com/ID?access_token=TOKENVALUE
Graph API Permissions

 Access to specific types of graph objects is controlled by
 permissions
   user_likes, friends_photos, publish_stream etc
   Requested via scope parameter in OAuth 2.0 request
   Balance app functionality against intrusiveness
Searching
 GET https://graph.facebook.com/search?q=force.com&type=post
Publishing

 HTTP POST to a connection URL
   Access token is required!
   curl -F 'access_token=...' 
       -F 'message=Hello world!' 
       https://graph.facebook.com/me/feed
   Response: {"id":"667905711_10151088147280712"}
Graph API Explorer

        https://developers.facebook.com/tools/explorer
Force.com Toolkit for Facebook
 http://wiki.developerforce.com/page/Facebook_Toolkit
 Apex binding for the Facebook Graph API
  Map<String,String> params =
      new Map<string,string>{'fields' => 'id,name',
                    'limit' => '10'};
  FacebookUsers friends =
      new FacebookUsers(access_token, 'me/friends', params);
  for (FacebookUser friend : friends.data) {
      System.debug(friend.name);
  }
Force.com Toolkit for Facebook

 Graph API objects modeled as Apex classes
   FacebookUser, FacebookPhoto etc
  <apex:page controller=“FriendsController”>
    <apex:pageSectionTable value=“{!friends}” var=“friend”>
      <apex:column value=“{!friend.name}”>
    </apex:pageSectionTable>
  </apex:page>



 Open source, but unsupported
Social Sign-On from Facebook to
Customer Portal
 Authentication Provider
   Built into Force.com Platform
   Performs ‘app’ side of OAuth flow
   Maps Facebook user to Customer Portal user via Registration Handler
    class
   Can also map to org users, but not as useful in the Facebook context!
Leveraging the Social Graph

 How do we get our customer portal to ‘go viral’?
   Allow users to invite their friends
   Super-easy from JavaScript in a Visualforce page with Facebook Dialogs
  FB.ui({
   method: 'send',
   to: '123456789',
   name: 'Check out this great site!',
   description: 'My Portal has everything you need.’,
   link: 'http://myportalurl.force.com/',
  });
Building a Social App

 Want to (optionally) publish a link to the user’s wall when they
 close a case – encourage more friends to come use the portal!


 Can we show a checkbox to allow the user to publish to their
 wall at the time they close the case, with no Facebook dialog?
Getting an Access Token – Customer Portal
  public class MyPageController {
       private static String authProviderId = // Get custom setting;
       public String getAccessToken(){
             Auth.AuthToken.getAccessToken(authProviderId, 'facebook');
       }
       ...
  }


  <apex:page controller=”MyPageController”
      cache="false" sidebar="false" showHeader="false” title=”My Page”>
One Shortcoming with Authentication Provider

 scope is fixed to email
   email address + ‘basic info’ (friends list etc)


 Right now, out of the box, Authentication Providers work great
 for Social Sign-On, but don’t allow very rich social apps


 Unless…
Widening Scope

Workaround for fixed scope
    Use Facebook JavaScript SDK to request additional permissions

   // We need some permissions - ask for them
   FB.login(function(response) {
    if (!response) {
        alert('Error getting permission!');
    } else {
        location.reload(true);
    }
   }, {scope: reqperms});
Wrapping Up

 The Facebook JavaScript SDK and Dialogs allow simple social
 actions from Visualforce

 The Force.com Toolkit for Facebook gives access to the Graph
 API from Apex

 Authentication Providers allow Social Sign-On to customer
 portals
Go out and build something cool!
Pat Patterson
Principal Developer Evangelist,
         @metadaddy
Social Apps with the Force.com Toolkit for Facebook

Weitere ähnliche Inhalte

Was ist angesagt?

The SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.js
The SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.jsThe SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.js
The SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.jsShashank Srivatsavaya (ShashForce)
 
Online tools for content development
Online tools for content developmentOnline tools for content development
Online tools for content developmentZulechaGenAlzate
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRight IT Services
 
Rits Brown Bag - Salesforce AppExchange
Rits Brown Bag - Salesforce AppExchangeRits Brown Bag - Salesforce AppExchange
Rits Brown Bag - Salesforce AppExchangeRight IT Services
 
Salesforce Spring 17 Release Overview
Salesforce Spring 17 Release OverviewSalesforce Spring 17 Release Overview
Salesforce Spring 17 Release OverviewRoy Gilad
 
Salesforce Summer 14 Release Notes (Alexandra Vilks)
Salesforce Summer 14 Release Notes (Alexandra Vilks)Salesforce Summer 14 Release Notes (Alexandra Vilks)
Salesforce Summer 14 Release Notes (Alexandra Vilks)Yury Bondarau
 
Developing on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not CodeDeveloping on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not CodeSalesforce Developers
 
Salesforce Development Training In Noida Delhi NCR
Salesforce Development Training In Noida Delhi NCRSalesforce Development Training In Noida Delhi NCR
Salesforce Development Training In Noida Delhi NCRShri Prakash Pandey
 
Developers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformDevelopers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformJohn Stevenson
 
Developer Tour on the Salesforce1 Platform
Developer Tour on the Salesforce1 PlatformDeveloper Tour on the Salesforce1 Platform
Developer Tour on the Salesforce1 PlatformSalesforce Deutschland
 

Was ist angesagt? (16)

Facebook Apps
Facebook AppsFacebook Apps
Facebook Apps
 
The SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.js
The SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.jsThe SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.js
The SEAN stack - Build Web Apps With Salesforce, Express, Angular and Node.js
 
portfolio
portfolioportfolio
portfolio
 
Online tools for content development
Online tools for content developmentOnline tools for content development
Online tools for content development
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce Lightning
 
Ponakaladinne reddy
Ponakaladinne reddyPonakaladinne reddy
Ponakaladinne reddy
 
Rits Brown Bag - Salesforce AppExchange
Rits Brown Bag - Salesforce AppExchangeRits Brown Bag - Salesforce AppExchange
Rits Brown Bag - Salesforce AppExchange
 
Social Media
Social MediaSocial Media
Social Media
 
Salesforce Spring 17 Release Overview
Salesforce Spring 17 Release OverviewSalesforce Spring 17 Release Overview
Salesforce Spring 17 Release Overview
 
Build lightning components with salesforce dx
Build lightning components with salesforce dxBuild lightning components with salesforce dx
Build lightning components with salesforce dx
 
Salesforce Summer 14 Release Notes (Alexandra Vilks)
Salesforce Summer 14 Release Notes (Alexandra Vilks)Salesforce Summer 14 Release Notes (Alexandra Vilks)
Salesforce Summer 14 Release Notes (Alexandra Vilks)
 
Developing on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not CodeDeveloping on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not Code
 
Mobile seo
Mobile seoMobile seo
Mobile seo
 
Salesforce Development Training In Noida Delhi NCR
Salesforce Development Training In Noida Delhi NCRSalesforce Development Training In Noida Delhi NCR
Salesforce Development Training In Noida Delhi NCR
 
Developers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformDevelopers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 Platform
 
Developer Tour on the Salesforce1 Platform
Developer Tour on the Salesforce1 PlatformDeveloper Tour on the Salesforce1 Platform
Developer Tour on the Salesforce1 Platform
 

Ähnlich wie Social Apps with the Force.com Toolkit for Facebook

REST API: Do More in the Feed with Action Links
REST API: Do More in the Feed with Action LinksREST API: Do More in the Feed with Action Links
REST API: Do More in the Feed with Action LinksSalesforce Developers
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersSalesforce Developers
 
[MBF2] Plate-forme Salesforce par Peter Chittum
[MBF2] Plate-forme Salesforce par Peter Chittum[MBF2] Plate-forme Salesforce par Peter Chittum
[MBF2] Plate-forme Salesforce par Peter ChittumBeMyApp
 
Integrate Business Apps with Facebook, Twitter, and LinkedIn
Integrate Business Apps with Facebook, Twitter, and LinkedInIntegrate Business Apps with Facebook, Twitter, and LinkedIn
Integrate Business Apps with Facebook, Twitter, and LinkedInSalesforce Developers
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introductionh_marvin
 
Business Mashups Best of the Web APIs
Business Mashups Best of the Web APIsBusiness Mashups Best of the Web APIs
Business Mashups Best of the Web APIsdreamforce2006
 
CRM Science - Dreamforce '14: Using the Google SOAP API
CRM Science - Dreamforce '14: Using the Google SOAP APICRM Science - Dreamforce '14: Using the Google SOAP API
CRM Science - Dreamforce '14: Using the Google SOAP APICRMScienceKirk
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce dataSalesforce Developers
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforceMark Adcock
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platformJohn Stevenson
 
Salesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep DiveSalesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep DiveSalesforce Developers
 
Introduction to the Salesforce Mobile SDK for Android
Introduction to the Salesforce Mobile SDK for AndroidIntroduction to the Salesforce Mobile SDK for Android
Introduction to the Salesforce Mobile SDK for AndroidSalesforce Developers
 
JDF18 - Connecting the customer success platform
JDF18 - Connecting the customer success platformJDF18 - Connecting the customer success platform
JDF18 - Connecting the customer success platformDeepu Chacko
 
Authentication with OAuth and Connected Apps
Authentication with OAuth and Connected AppsAuthentication with OAuth and Connected Apps
Authentication with OAuth and Connected AppsSalesforce Developers
 
Dive Deep Into the Force.com Canvas Framework
Dive Deep Into the Force.com Canvas FrameworkDive Deep Into the Force.com Canvas Framework
Dive Deep Into the Force.com Canvas FrameworkSalesforce Developers
 
Navi Mumbai Salesforce DUG meetup on integration
Navi Mumbai Salesforce DUG meetup on integrationNavi Mumbai Salesforce DUG meetup on integration
Navi Mumbai Salesforce DUG meetup on integrationRakesh Gupta
 
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectExploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectSalesforce Developers
 
Force.com Canvas: 2 Case Studies and a Roadmap
Force.com Canvas: 2 Case Studies and a RoadmapForce.com Canvas: 2 Case Studies and a Roadmap
Force.com Canvas: 2 Case Studies and a RoadmapSalesforce Developers
 

Ähnlich wie Social Apps with the Force.com Toolkit for Facebook (20)

REST API: Do More in the Feed with Action Links
REST API: Do More in the Feed with Action LinksREST API: Do More in the Feed with Action Links
REST API: Do More in the Feed with Action Links
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for Beginners
 
[MBF2] Plate-forme Salesforce par Peter Chittum
[MBF2] Plate-forme Salesforce par Peter Chittum[MBF2] Plate-forme Salesforce par Peter Chittum
[MBF2] Plate-forme Salesforce par Peter Chittum
 
Integrate Business Apps with Facebook, Twitter, and LinkedIn
Integrate Business Apps with Facebook, Twitter, and LinkedInIntegrate Business Apps with Facebook, Twitter, and LinkedIn
Integrate Business Apps with Facebook, Twitter, and LinkedIn
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
Business Mashups Best of the Web APIs
Business Mashups Best of the Web APIsBusiness Mashups Best of the Web APIs
Business Mashups Best of the Web APIs
 
CRM Science - Dreamforce '14: Using the Google SOAP API
CRM Science - Dreamforce '14: Using the Google SOAP APICRM Science - Dreamforce '14: Using the Google SOAP API
CRM Science - Dreamforce '14: Using the Google SOAP API
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
 
Salesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep DiveSalesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep Dive
 
Introduction to the Salesforce Mobile SDK for Android
Introduction to the Salesforce Mobile SDK for AndroidIntroduction to the Salesforce Mobile SDK for Android
Introduction to the Salesforce Mobile SDK for Android
 
JDF18 - Connecting the customer success platform
JDF18 - Connecting the customer success platformJDF18 - Connecting the customer success platform
JDF18 - Connecting the customer success platform
 
Winter'18 Developer Preview Webinar
Winter'18 Developer Preview WebinarWinter'18 Developer Preview Webinar
Winter'18 Developer Preview Webinar
 
Authentication with OAuth and Connected Apps
Authentication with OAuth and Connected AppsAuthentication with OAuth and Connected Apps
Authentication with OAuth and Connected Apps
 
Introduction to Apex for Developers
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for Developers
 
Dive Deep Into the Force.com Canvas Framework
Dive Deep Into the Force.com Canvas FrameworkDive Deep Into the Force.com Canvas Framework
Dive Deep Into the Force.com Canvas Framework
 
Navi Mumbai Salesforce DUG meetup on integration
Navi Mumbai Salesforce DUG meetup on integrationNavi Mumbai Salesforce DUG meetup on integration
Navi Mumbai Salesforce DUG meetup on integration
 
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectExploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning Connect
 
Force.com Canvas: 2 Case Studies and a Roadmap
Force.com Canvas: 2 Case Studies and a RoadmapForce.com Canvas: 2 Case Studies and a Roadmap
Force.com Canvas: 2 Case Studies and a Roadmap
 

Mehr von Salesforce Developers

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSalesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceSalesforce Developers
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base ComponentsSalesforce Developers
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsSalesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaSalesforce Developers
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentSalesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsSalesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsSalesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsSalesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and TestingSalesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionSalesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPSalesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceSalesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureSalesforce Developers
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DXSalesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectSalesforce Developers
 

Mehr von Salesforce Developers (20)

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
 
Introduction to MuleSoft
Introduction to MuleSoftIntroduction to MuleSoft
Introduction to MuleSoft
 

Social Apps with the Force.com Toolkit for Facebook

  • 1. Social Apps with the Force.com Toolkit for Facebook Pat Patterson, salesforce.com, Principal Developer Evangelist @metadaddy
  • 2. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward- looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 3. Pat Patterson Principal Developer Evangelist @metadaddy
  • 4. Objectives Understand the Facebook Graph API Be able to use the Force.com Toolkit for Facebook in an app Understand how users can use their Facebook identity to login to Salesforce
  • 5. Agenda The Facebook Graph API The Force.com Toolkit for Facebook Social Sign-On with Authentication Providers Create a social application on Force.com  Login from Facebook  Share with friends  Post to timeline
  • 6. The Facebook Graph API https://developers.facebook.com/docs/reference/api/
  • 7. Accessing Social Graph Objects Every social graph object has a unique ID  https://graph.facebook.com/ID For example, ‘Facebook Platform’ has ID 19292868552  GET https://graph.facebook.com/19292868552
  • 8. Relationships – Edges on the Graph Friends, feed (wall/timeline), likes, photos, videos, etc Graph API terminology: connections  https://graph.facebook.com/ID/CONNECTION_TYPE For example, my friends  Special ID - me  GET https://graph.facebook.com/me/friends
  • 9. Graph API Authorization OAuth 2.0  Redirect to Facebook; user authenticates (if necessary) and gives permission for app to access the Graph API  App receives access token representing the user’s permission to access their social graph  App sends access token with Graph API calls as a query parameter https://graph.facebook.com/ID?access_token=TOKENVALUE
  • 10. Graph API Permissions Access to specific types of graph objects is controlled by permissions  user_likes, friends_photos, publish_stream etc  Requested via scope parameter in OAuth 2.0 request  Balance app functionality against intrusiveness
  • 12. Publishing HTTP POST to a connection URL  Access token is required!  curl -F 'access_token=...' -F 'message=Hello world!' https://graph.facebook.com/me/feed  Response: {"id":"667905711_10151088147280712"}
  • 13. Graph API Explorer https://developers.facebook.com/tools/explorer
  • 14. Force.com Toolkit for Facebook http://wiki.developerforce.com/page/Facebook_Toolkit Apex binding for the Facebook Graph API Map<String,String> params = new Map<string,string>{'fields' => 'id,name', 'limit' => '10'}; FacebookUsers friends = new FacebookUsers(access_token, 'me/friends', params); for (FacebookUser friend : friends.data) { System.debug(friend.name); }
  • 15. Force.com Toolkit for Facebook Graph API objects modeled as Apex classes  FacebookUser, FacebookPhoto etc <apex:page controller=“FriendsController”> <apex:pageSectionTable value=“{!friends}” var=“friend”> <apex:column value=“{!friend.name}”> </apex:pageSectionTable> </apex:page> Open source, but unsupported
  • 16. Social Sign-On from Facebook to Customer Portal Authentication Provider  Built into Force.com Platform  Performs ‘app’ side of OAuth flow  Maps Facebook user to Customer Portal user via Registration Handler class  Can also map to org users, but not as useful in the Facebook context!
  • 17. Leveraging the Social Graph How do we get our customer portal to ‘go viral’?  Allow users to invite their friends  Super-easy from JavaScript in a Visualforce page with Facebook Dialogs FB.ui({ method: 'send', to: '123456789', name: 'Check out this great site!', description: 'My Portal has everything you need.’, link: 'http://myportalurl.force.com/', });
  • 18. Building a Social App Want to (optionally) publish a link to the user’s wall when they close a case – encourage more friends to come use the portal! Can we show a checkbox to allow the user to publish to their wall at the time they close the case, with no Facebook dialog?
  • 19. Getting an Access Token – Customer Portal public class MyPageController { private static String authProviderId = // Get custom setting; public String getAccessToken(){ Auth.AuthToken.getAccessToken(authProviderId, 'facebook'); } ... } <apex:page controller=”MyPageController” cache="false" sidebar="false" showHeader="false” title=”My Page”>
  • 20. One Shortcoming with Authentication Provider scope is fixed to email  email address + ‘basic info’ (friends list etc) Right now, out of the box, Authentication Providers work great for Social Sign-On, but don’t allow very rich social apps Unless…
  • 21. Widening Scope Workaround for fixed scope  Use Facebook JavaScript SDK to request additional permissions // We need some permissions - ask for them FB.login(function(response) { if (!response) { alert('Error getting permission!'); } else { location.reload(true); } }, {scope: reqperms});
  • 22. Wrapping Up The Facebook JavaScript SDK and Dialogs allow simple social actions from Visualforce The Force.com Toolkit for Facebook gives access to the Graph API from Apex Authentication Providers allow Social Sign-On to customer portals
  • 23. Go out and build something cool!
  • 24. Pat Patterson Principal Developer Evangelist, @metadaddy