API-Driven Relationships
Building The Trans-Internet Express of the Future
Pat Patterson
Developer Evangelist Architect
@metadaddy
Apps
Image used under CC-BY-SA.
Attribution: SeeSchloss on en.wikipedia.org
APIs
Image used under CC-BY-SA.
Attribution: Daniel Schwen on en.wikipedia.org
Identity
Image used under CC-BY-SA.
Attribution: Arne Hückelheim on en.wikipedia.org
Integrating Issues from GitHub into Salesforce1
•I’m tracking support cases in Service Cloud
•Some of my products are also open source projects
•I want to…
–link Service Cloud Case records to GitHub Issues
–manage links from the Salesforce1 Mobile App
Salesforce1 Mobile App
Run Your Business From Your Phone
• Mobile access to data in Salesforce
– Accounts, Contacts, Cases etc
– Custom Objects
• Extension points for customization
– PublisherActions
– CustomApps
Containerization
Image used under CC-BY-SA. Attribution: Simeon87 on en.wikipedia.org
GitHub API
•Resources:
–Repositories, issues, comments, file contents etc
–Hyperlinked
•Authentication:
–None
–Basic
–OAuth 2.0
REST
GitHub API
Example call
$curlhttps://api.github.com/users/metadaddy-sfdc
{
"login": "metadaddy-sfdc",
"id":723517,
"avatar_url": "https://avatars.githubusercontent.com/u/723517?",
"gravatar_id": "19573811373a51e4d063f9be63a5ac7c",
"url":"https://api.github.com/users/metadaddy-sfdc",
"html_url": "https://github.com/metadaddy-sfdc",
"followers_url": "https://api.github.com/users/metadaddy-sfdc/followers",
"following_url": "https://api.github.com/users/metadaddy-sfdc/following{/other_user}",
"repos_url":"https://api.github.com/users/metadaddy-sfdc/repos",
"type": "User",
"name":"Pat Patterson",
"company": "salesforce.com",
"location": "SanFrancisco, CA",
"bio":"Principal Developer Evangelist at salesforce.com",
"public_repos": 55,
"public_gists": 31,
}
Issues in GitHub
‘Single-page app’ built with Ionic Framework and AngularJS
• Custom ‘GitHub URL’ field on Salesforce Case
object
• Custom ‘GitHub token’field on Salesforce User
object
• Login to GitHub via OAuth 2.0
• Pull my open Issues via GitHubAPI
• Set value of GitHub URL field on Case
github.com/metadaddy-sfdc/IssuesInGitHub
Demo
Issues in GitHub
Automating Salesforce ExactTarget Marketing Cloud
• I use ExactTarget for email marketing
• My users log in to a community site via Facebook and other social
providers
• I want to…
– automatically add new users to ExactTarget
– send new users a personalized welcome email
Double Header
Image used under CC-BY. Attribution: chief_huddleston on Flickr
ExactTarget APIs
Authentication – App-to-App
• Request
POST/v1/requestToken
Host:auth.exacttargetapis.com
Content-type: application/json
{
"clientSecret":"jY3CejwqkeqhelkqweetMKh",
"clientId":"qew7rehjlrhlehrlwerwbfbfh49w”
}
• Response
{
"accessToken":"uuqxk7rf5f7ddpy7f5f4m74u",
"expiresIn":3550
}
ExactTarget APIs
Web Service (SOAP)
• Manage Subscribers, Lists, Campaigns etc
<s:Envelopexmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Actions:mustUnderstand="1">Create</a:Action>
<a:Tos:mustUnderstand="1">https://webservice.exacttarget.com/Service.asmx</a:To>
<ns1:fueloauthxmlns:ns1="http://exacttarget.com">uuqxk7rf5f7ddpy7f5f4m74u</ns1:fueloauth>
</s:Header>
<s:Bodyxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CreateRequestxmlns="http://exacttarget.com/wsdl/partnerAPI">
<Objectsxsi:type="Subscriber">
<EmailAddress>demo@salesforceidentity.info</EmailAddress>
<SubscriberKey>demo@salesforceidentity.info</SubscriberKey>
</Objects>
</CreateRequest>
</s:Body>
</s:Envelope>
Image used under CC-BY-SA.
Attribution: François Melchior on en.wikipedia.org
SOAP
ExactTarget APIs
Fuel API (REST)
• Trigger events, send SMS, mobile app notifications
POST/interaction-experimental/v1/events
Host:www.exacttargetapis.com
Authorization: Bearer uuqxk7rf5f7ddpy7f5f4m74u
Content-type: application/json
{
"ContactKey": "demo@salesforceidentity.info",
"Data": {
"Facebook_ID__c": "100001234567890",
"First_Name__c": ”Demo",
"Last_Name__c": ”User",
"Locale__c": "en_US",
"User_Email__c": "demo@salesforceidentity.info"
},
"EventDefinitionKey": "Facebook-User-c-trigger"
}
REST
Image used under CC-BY-SA.
Attribution: Daniel Schwen on en.wikipedia.org
Demo
Communities / ExactTarget Integration
Visualizing Business Data… in Minecraft
• I build Minecraft mods with my kids
• I want to see data from Salesforce in a Minecraft world
Image used under CC-BY. Attribution: Rklawton on en.wikipedia.org
Fun!
Salesforce Identity
OAuth 2.0 (Resource Owner Password Credentials Grant)
• Request
POST/services/oauth2/token
Host:login.salesforce.com
Content-type:application/x-www-form-urlencoded
grant_type=password&client_id=3MV...&client_secret=123...&username=user@example.com&password=password
• Response
{
"id":"https://login.salesforce.com/id/00D50000000IZ3ZEAW/00550000001fg5OAAQ",
"issued_at":"1296509381665",
"instance_url":"https://na1.salesforce.com",
"signature":"+Nbl5EOl/DlsvUZ4NbGDno6vn935XsWGVbwoKyXHayo=",
"access_token":"00D50000000IZ3Z!AQgAQH0Yd9M51BU_rayzAdmZ6NmT3pXZ1kTuuQPljJVsX4CPt3naL7qustlb"
}
Salesforce1 Platform
Force.com REST API
• Queries
– SOQLor SOSL query passed as URLparameter
• /services/data/v29.0/query?q=SELECT+Id,+Name+FROM+Account…
• Resources
– Object types and records in database
• /services/data/v29.0/sobjects/
• /services/data/v29.0/sobjects/Account/
• /services/data/v29.0/sobjects/Account/001i000000b64Rw
Salesforce1 Platform
Force.com Streaming API
• Bayeux wire protocol
– HTTP Long Polling
• CometD Client Libraries
client = new BayeuxClient(salesforceStreamingEndpoint(endpoint), transport);
...
client.getChannel(OPPORTUNITY_CHANNEL).subscribe(new OpportunityListener());
...
public class OpportunityListener implements MessageListener {
public void onMessage(ClientSessionChannel channel, Message message) {
}
}
Demo
Forcecraft
github.com/metadaddy-sfdc/Forcecraft
Just as standard rail gauge and couplings
allowed the railways to flourish, identity
standards such as OAuth 2.0 and OpenID
Connect, and standard API patterns such as
REST, allow us to build the Trans-Internet
Express of the future.
API-Driven Relationships: Building The Trans-Internet Express of the Future

API-Driven Relationships: Building The Trans-Internet Express of the Future

  • 1.
    API-Driven Relationships Building TheTrans-Internet Express of the Future Pat Patterson Developer Evangelist Architect @metadaddy
  • 2.
    Apps Image used underCC-BY-SA. Attribution: SeeSchloss on en.wikipedia.org APIs Image used under CC-BY-SA. Attribution: Daniel Schwen on en.wikipedia.org Identity Image used under CC-BY-SA. Attribution: Arne Hückelheim on en.wikipedia.org
  • 3.
    Integrating Issues fromGitHub into Salesforce1 •I’m tracking support cases in Service Cloud •Some of my products are also open source projects •I want to… –link Service Cloud Case records to GitHub Issues –manage links from the Salesforce1 Mobile App
  • 4.
    Salesforce1 Mobile App RunYour Business From Your Phone • Mobile access to data in Salesforce – Accounts, Contacts, Cases etc – Custom Objects • Extension points for customization – PublisherActions – CustomApps Containerization Image used under CC-BY-SA. Attribution: Simeon87 on en.wikipedia.org
  • 5.
    GitHub API •Resources: –Repositories, issues,comments, file contents etc –Hyperlinked •Authentication: –None –Basic –OAuth 2.0 REST
  • 6.
    GitHub API Example call $curlhttps://api.github.com/users/metadaddy-sfdc { "login":"metadaddy-sfdc", "id":723517, "avatar_url": "https://avatars.githubusercontent.com/u/723517?", "gravatar_id": "19573811373a51e4d063f9be63a5ac7c", "url":"https://api.github.com/users/metadaddy-sfdc", "html_url": "https://github.com/metadaddy-sfdc", "followers_url": "https://api.github.com/users/metadaddy-sfdc/followers", "following_url": "https://api.github.com/users/metadaddy-sfdc/following{/other_user}", "repos_url":"https://api.github.com/users/metadaddy-sfdc/repos", "type": "User", "name":"Pat Patterson", "company": "salesforce.com", "location": "SanFrancisco, CA", "bio":"Principal Developer Evangelist at salesforce.com", "public_repos": 55, "public_gists": 31, }
  • 7.
    Issues in GitHub ‘Single-pageapp’ built with Ionic Framework and AngularJS • Custom ‘GitHub URL’ field on Salesforce Case object • Custom ‘GitHub token’field on Salesforce User object • Login to GitHub via OAuth 2.0 • Pull my open Issues via GitHubAPI • Set value of GitHub URL field on Case github.com/metadaddy-sfdc/IssuesInGitHub
  • 8.
  • 9.
    Automating Salesforce ExactTargetMarketing Cloud • I use ExactTarget for email marketing • My users log in to a community site via Facebook and other social providers • I want to… – automatically add new users to ExactTarget – send new users a personalized welcome email Double Header Image used under CC-BY. Attribution: chief_huddleston on Flickr
  • 10.
    ExactTarget APIs Authentication –App-to-App • Request POST/v1/requestToken Host:auth.exacttargetapis.com Content-type: application/json { "clientSecret":"jY3CejwqkeqhelkqweetMKh", "clientId":"qew7rehjlrhlehrlwerwbfbfh49w” } • Response { "accessToken":"uuqxk7rf5f7ddpy7f5f4m74u", "expiresIn":3550 }
  • 11.
    ExactTarget APIs Web Service(SOAP) • Manage Subscribers, Lists, Campaigns etc <s:Envelopexmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <a:Actions:mustUnderstand="1">Create</a:Action> <a:Tos:mustUnderstand="1">https://webservice.exacttarget.com/Service.asmx</a:To> <ns1:fueloauthxmlns:ns1="http://exacttarget.com">uuqxk7rf5f7ddpy7f5f4m74u</ns1:fueloauth> </s:Header> <s:Bodyxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <CreateRequestxmlns="http://exacttarget.com/wsdl/partnerAPI"> <Objectsxsi:type="Subscriber"> <EmailAddress>demo@salesforceidentity.info</EmailAddress> <SubscriberKey>demo@salesforceidentity.info</SubscriberKey> </Objects> </CreateRequest> </s:Body> </s:Envelope> Image used under CC-BY-SA. Attribution: François Melchior on en.wikipedia.org SOAP
  • 12.
    ExactTarget APIs Fuel API(REST) • Trigger events, send SMS, mobile app notifications POST/interaction-experimental/v1/events Host:www.exacttargetapis.com Authorization: Bearer uuqxk7rf5f7ddpy7f5f4m74u Content-type: application/json { "ContactKey": "demo@salesforceidentity.info", "Data": { "Facebook_ID__c": "100001234567890", "First_Name__c": ”Demo", "Last_Name__c": ”User", "Locale__c": "en_US", "User_Email__c": "demo@salesforceidentity.info" }, "EventDefinitionKey": "Facebook-User-c-trigger" } REST Image used under CC-BY-SA. Attribution: Daniel Schwen on en.wikipedia.org
  • 13.
  • 14.
    Visualizing Business Data…in Minecraft • I build Minecraft mods with my kids • I want to see data from Salesforce in a Minecraft world Image used under CC-BY. Attribution: Rklawton on en.wikipedia.org Fun!
  • 15.
    Salesforce Identity OAuth 2.0(Resource Owner Password Credentials Grant) • Request POST/services/oauth2/token Host:login.salesforce.com Content-type:application/x-www-form-urlencoded grant_type=password&client_id=3MV...&client_secret=123...&username=user@example.com&password=password • Response { "id":"https://login.salesforce.com/id/00D50000000IZ3ZEAW/00550000001fg5OAAQ", "issued_at":"1296509381665", "instance_url":"https://na1.salesforce.com", "signature":"+Nbl5EOl/DlsvUZ4NbGDno6vn935XsWGVbwoKyXHayo=", "access_token":"00D50000000IZ3Z!AQgAQH0Yd9M51BU_rayzAdmZ6NmT3pXZ1kTuuQPljJVsX4CPt3naL7qustlb" }
  • 16.
    Salesforce1 Platform Force.com RESTAPI • Queries – SOQLor SOSL query passed as URLparameter • /services/data/v29.0/query?q=SELECT+Id,+Name+FROM+Account… • Resources – Object types and records in database • /services/data/v29.0/sobjects/ • /services/data/v29.0/sobjects/Account/ • /services/data/v29.0/sobjects/Account/001i000000b64Rw
  • 17.
    Salesforce1 Platform Force.com StreamingAPI • Bayeux wire protocol – HTTP Long Polling • CometD Client Libraries client = new BayeuxClient(salesforceStreamingEndpoint(endpoint), transport); ... client.getChannel(OPPORTUNITY_CHANNEL).subscribe(new OpportunityListener()); ... public class OpportunityListener implements MessageListener { public void onMessage(ClientSessionChannel channel, Message message) { } }
  • 18.
  • 19.
    Just as standardrail gauge and couplings allowed the railways to flourish, identity standards such as OAuth 2.0 and OpenID Connect, and standard API patterns such as REST, allow us to build the Trans-Internet Express of the future.