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