+ All Categories
Home > Technology > Salesforce Integration with PHP

Salesforce Integration with PHP

Date post: 18-Nov-2014
Category:
Upload: toivo-talikka
View: 19,024 times
Download: 2 times
Share this document with a friend
Description:
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
18
Salesforce Integration with PHP A Sydney PHP Group Presentation April 3 rd 2008 Toivo Talikka http://totaldata.biz
Transcript
Page 1: Salesforce Integration with PHP

Salesforce Integration with PHP

A Sydney PHP Group PresentationApril 3rd 2008

Toivo Talikkahttp://totaldata.biz

Page 2: Salesforce Integration with PHP

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

Page 3: Salesforce Integration with PHP

User Interface

Page 4: Salesforce Integration with PHP

Integration With PHP

Web Services API

PHP Toolkit

Page 5: Salesforce Integration with PHP

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

Page 6: Salesforce Integration with PHP

Web Services

Page 7: Salesforce Integration with PHP

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

Page 8: Salesforce Integration with PHP

Sales Objects

Page 9: Salesforce Integration with PHP

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

Page 10: Salesforce Integration with PHP

SOQL

Comparison operators: = != < <= > >= like: case insensitive matching

Wildcards % and _

Logical operators: and, or, not

Boolean filtering where BooleanField = TRUE where BooleanField = FALSE

Page 11: Salesforce Integration with PHP

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

Page 12: Salesforce Integration with PHP

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

Page 13: Salesforce Integration with PHP

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'

Page 14: Salesforce Integration with PHP

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;

}

Page 15: Salesforce Integration with PHP

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."'";

Page 16: Salesforce Integration with PHP

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;

Page 17: Salesforce Integration with PHP

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;

Page 18: Salesforce Integration with PHP

APEX Data Loader

Download tables as CSV files

Test queries before using API


Recommended