Salesforce Integration with PHP A Sydney PHP Group Presentation April 3 rd  2008 Toivo Talikka http://totaldata.biz
Salesforce.com <ul><li>On-demand CRM vendor </li></ul><ul><ul><li>software as a Service (SaaS) </li></ul></ul><ul><ul><li>...
User Interface
Integration With PHP <ul><li>Web Services API </li></ul><ul><li>PHP Toolkit </li></ul>
PHP  Toolkit <ul><li>Self Service Portal Toolkit For PHP 5 </li></ul><ul><ul><li>v0.9.1  11 May 2006 </li></ul></ul><ul><u...
Web Services
Data Model <ul><li>Entity Relationship Diagrams for objects </li></ul><ul><ul><li>Sales </li></ul></ul><ul><ul><ul><li>Acc...
Sales Objects
SOQL <ul><li>Salesforce Object Query Language </li></ul><ul><li>500 row limit to rows in the query result object in a quer...
SOQL <ul><li>Comparison operators:  </li></ul><ul><ul><li>=  !=  <  <=  >  >= </li></ul></ul><ul><ul><li>like: case insens...
Multi-Select Picklists <ul><li>'AAA;BBB'  means 'AAA' and 'BBB‘ </li></ul><ul><li>MSP1__c = 'AAA;BBB'  : exact match </li>...
Relationship Queries <ul><li>Must have relationship between objects to create a join in SOQL </li></ul><ul><li>Only one le...
Query Example <ul><li>Company and contact details </li></ul><ul><li>Select Id, Name, Type, BillingStreet, BillingCity, Bil...
Returned Objects <ul><li>$query = &quot;SELECT Id, FirstName, LastName from Contact&quot;; </li></ul><ul><li>$queryResult ...
Relationship Query <ul><li>$query = 'Select a.Id, a.Name, a.Type, '; </li></ul><ul><li>$query .= ' a.BillingStreet, a.Bill...
queryResult Array <ul><li>foreach ($records as $record) { </li></ul><ul><li>$Account = new SObject($record); </li></ul><ul...
Objects and Arrays <ul><li>Select c.FirstName, c.LastName, a.Name </li></ul><ul><li>FROM Contact c. c.Account </li></ul><u...
APEX Data Loader Download tables as CSV files Test queries before using API
Upcoming SlideShare
Loading in …5
×

Salesforce Integration with PHP

15,154 views

Published on

A Sydney PHP Group presentation
April 3rd 2008
Toivo Talikka
http://totaldata.biz

Connecting to Salesforce.com using Web Services API from PHP Toolkit and SOQL query examples

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
  • How to get relational query result? for example
    SELECT ID, Name, Parent__r.id, Parent__r.name
    FROM Child__c
    ORDER BY Parent__r.name
    Here I can`t get Parent__r.id, Parent__r.name values like bellow
    $id = $sObject->fields->Parent__r.id;
    $name = $sObject->fields-> Parent__r.name;

    Then what I have to write to get these values?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
15,154
On SlideShare
0
From Embeds
0
Number of Embeds
136
Actions
Shares
0
Downloads
186
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

Salesforce Integration with PHP

  1. 1. Salesforce Integration with PHP A Sydney PHP Group Presentation April 3 rd 2008 Toivo Talikka http://totaldata.biz
  2. 2. Salesforce.com <ul><li>On-demand CRM vendor </li></ul><ul><ul><li>software as a Service (SaaS) </li></ul></ul><ul><ul><li>CRM and business applications </li></ul></ul><ul><ul><li>Application Exchange </li></ul></ul><ul><ul><li>APEX Developer Network </li></ul></ul><ul><li>Standard Objects: </li></ul><ul><ul><li>Account </li></ul></ul><ul><ul><li>Contact </li></ul></ul><ul><ul><li>Opportunity </li></ul></ul><ul><ul><li>Lead </li></ul></ul><ul><li>Customers can add own fields </li></ul>
  3. 3. User Interface
  4. 4. Integration With PHP <ul><li>Web Services API </li></ul><ul><li>PHP Toolkit </li></ul>
  5. 5. PHP Toolkit <ul><li>Self Service Portal Toolkit For PHP 5 </li></ul><ul><ul><li>v0.9.1 11 May 2006 </li></ul></ul><ul><ul><li>Embeds Self Service Portal to a website </li></ul></ul><ul><ul><li>Authenticate user, login to Salesforce </li></ul></ul><ul><li>PHP Toolkit 11 </li></ul><ul><ul><li>v11.0b 15/2/2008, supports API v11.1 </li></ul></ul><ul><ul><li>Web Service API calls </li></ul></ul><ul><ul><li>Requires PHP 5.1.2+ </li></ul></ul><ul><ul><li>SOAP enabled </li></ul></ul><ul><ul><li>SSL enabled </li></ul></ul>
  6. 6. Web Services
  7. 7. Data Model <ul><li>Entity Relationship Diagrams for objects </li></ul><ul><ul><li>Sales </li></ul></ul><ul><ul><ul><li>Accounts, contacts, opportunities, leads, campaigns </li></ul></ul></ul><ul><ul><li>Task and Event </li></ul></ul><ul><ul><li>Support </li></ul></ul><ul><ul><li>Document, Note and Attachment </li></ul></ul><ul><ul><li>User and Profile </li></ul></ul><ul><ul><li>Record Type </li></ul></ul><ul><ul><li>Product and Schedule </li></ul></ul><ul><ul><li>Sharing and Team Selling </li></ul></ul><ul><ul><li>Customizable Forecasting </li></ul></ul><ul><ul><li>Territory Management </li></ul></ul><ul><ul><li>Process </li></ul></ul>
  8. 8. Sales Objects
  9. 9. SOQL <ul><li>Salesforce Object Query Language </li></ul><ul><li>500 row limit to rows in the query result object in a query or queryMore call </li></ul><ul><li>Client application can change batch size in QueryOptions of SOAP header before invoking the query call </li></ul><ul><li>Daily maximum number of API calls </li></ul>
  10. 10. SOQL <ul><li>Comparison operators: </li></ul><ul><ul><li>= != < <= > >= </li></ul></ul><ul><ul><li>like: case insensitive matching </li></ul></ul><ul><ul><ul><li>Wildcards % and _ </li></ul></ul></ul><ul><li>Logical operators: and, or, not </li></ul><ul><li>Boolean filtering </li></ul><ul><ul><li>where BooleanField = TRUE </li></ul></ul><ul><ul><li>where BooleanField = FALSE </li></ul></ul>
  11. 11. Multi-Select Picklists <ul><li>'AAA;BBB' means 'AAA' and 'BBB‘ </li></ul><ul><li>MSP1__c = 'AAA;BBB' : exact match </li></ul><ul><li>MSP1__c includes ('AAA;BBB', 'CCC') </li></ul><ul><ul><li>either: AAA and BBB selected </li></ul></ul><ul><ul><li>or: CCC selected </li></ul></ul>
  12. 12. Relationship Queries <ul><li>Must have relationship between objects to create a join in SOQL </li></ul><ul><li>Only one level of parent-to-child relationship can be specified in a query </li></ul><ul><li>SELECT Account.Name, (SELECT Note.OwnerId FROM Account.Notes) FROM Account </li></ul>
  13. 13. Query Example <ul><li>Company and contact details </li></ul><ul><li>Select Id, Name, Type, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, Phone, Fax, Website, (SELECT LastName, FirstName, Title, Email, FROM Account.Contacts ) FROM Account WHERE id = '00120000001pKpFAAU' </li></ul>
  14. 14. Returned Objects <ul><li>$query = &quot;SELECT Id, FirstName, LastName from Contact&quot;; </li></ul><ul><li>$queryResult = $mySforceConnection->query($query); </li></ul><ul><li>$records = $queryResult->records; </li></ul><ul><li>foreach ($records as $record) { $sObject = new SObject ($record); echo &quot;Id = &quot;. $sObject->Id ; echo &quot;First Name = &quot;. $sObject->fields->FirstName ; echo &quot;Last Name = &quot;. $sObject->fields->LastName ; </li></ul><ul><li>} </li></ul>
  15. 15. Relationship Query <ul><li>$query = 'Select a.Id, a.Name, a.Type, '; </li></ul><ul><li>$query .= ' a.BillingStreet, a.BillingCity,'; </li></ul><ul><li>$query .= ' a.BillingCountry, a.Phone, a.Fax,'; </li></ul><ul><li>$query .= ' (SELECT c.LastName, c.FirstName, c.Title, c.Email FROM Account.Contacts c)'; </li></ul><ul><li>$query .= ' FROM Account a'; </li></ul><ul><li>$query .= &quot; WHERE Id = '&quot;.$account_id.&quot;'&quot;; </li></ul>
  16. 16. queryResult Array <ul><li>foreach ($records as $record) { </li></ul><ul><li>$Account = new SObject($record); </li></ul><ul><li>$id = $Account->Id; </li></ul><ul><li>$name = $Account->fields->Name; </li></ul><ul><li>… </li></ul><ul><li>$Contact_query_result = </li></ul><ul><li>$Account->queryResult[0]; </li></ul><ul><li>$Contacts = </li></ul><ul><li>$Contact_query_result->records; </li></ul><ul><li>foreach ($Contacts as $Contact) { </li></ul><ul><li>$first_name = $Contact->fields->FirstName; </li></ul><ul><li>$last_name = $Contact->fields->LastName; </li></ul>
  17. 17. Objects and Arrays <ul><li>Select c.FirstName, c.LastName, a.Name </li></ul><ul><li>FROM Contact c. c.Account </li></ul><ul><li>… </li></ul><ul><li>$Contact = new SObject($record); </li></ul><ul><li>// echo var_dump($Contact); </li></ul><ul><li>// echo print_r(get_object_vars($Contact); </li></ul><ul><li>$first_name = $Contact->fields->FirstName; </li></ul><ul><li>$company = $Contact->sobjects[0]->fields->Name; </li></ul>
  18. 18. APEX Data Loader Download tables as CSV files Test queries before using API

×