- Generate WSDL from your Salesforce organization
- Download PHP Class library SoapClient
- Requirements
- PHP 5.x
- SOAP Enabled
- SSL Enabled
- cURL Enabled
- OpenSSL Enabled
- PHP Code
- More information PHP_Toolkit_20.0
// Salesforce Credential
define("USERNAME", "<<Salesforce UserName>>");
define("PASSWORD", "<<SalesforcePassword>>");
define("SECURITY_TOKEN", "<<SalesforcePassword>>");
require_once ('soapclient/SforceEnterpriseClient.php');
$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
Create Account
$a = new stdClass();
$a ->BillingCity='city';
$a ->BillingCountry='country';
$a ->BillingPostalCode='postcode';
$a ->BillingState='state';
$a ->BillingStreet='address_1';
$a->Phone='phone';
$a ->Name='Companyname';
$a ->RecordTypeId=$AccountRecordType;
$a ->ShippingCity='ShippingCity';
$a ->ShippingCountry='ShippingCountry';
$a ->ShippingPostalCode='ShippingPostalCode';
$a ->ShippingState='ShippingState';
$a ->ShippingStreet='ShippingStreet';
$response = $mySforceConnection ->create(array($a), 'Account');
//print_r($response);
$AccountId = $response[0]->id;
echo "Account Id". $AccountId ."<br/>";
Update Account
$a = new stdClass();
$a ->Id='
$a ->Id='
0035000000
o
1
afRAAQ
';
$a ->BillingCity='city';
$a ->BillingCountry='country';
$a ->BillingPostalCode='postcode';
$a ->BillingState='state';
$a ->BillingStreet='address_1';
$a->Phone='phone';
$a ->Name='Companyname';
$a ->RecordTypeId=$AccountRecordType;
$a ->ShippingCity='ShippingCity';
$a ->ShippingCountry='ShippingCountry';
$a ->ShippingPostalCode='ShippingPostalCode';
$a ->ShippingState='ShippingState';
$a ->ShippingStreet='ShippingStreet';
$response = $mySforceConnection ->upsert(array($a), 'Account');
//print_r($response);
$AccountId = $response[0]->id;
echo "Account Id". $AccountId ."<br/>";
Upsert Account
$a = new stdClass();
$a ->Id='
$a ->Id='
0035000000
o
1
afRAAQ
';
$a ->BillingCity='city';
$a ->BillingCountry='country';
$a ->BillingPostalCode='postcode';
$a ->BillingState='state';
$a ->BillingStreet='address_1';
$a->Phone='phone';
$a ->Name='Companyname';
$a ->RecordTypeId=$AccountRecordType;
$a ->ShippingCity='ShippingCity';
$a ->ShippingCountry='ShippingCountry';
$a ->ShippingPostalCode='ShippingPostalCode';
$a ->ShippingState='ShippingState';
$a ->ShippingStreet='ShippingStreet';
$response = $mySforceConnection ->upsert(array($a), 'Account');
//print_r($response);
$AccountId = $response[0]->id;
$isCreated= $response[0]->created; //To Check Account is to be update or Created
$isCreated= $response[0]->created; //To Check Account is to be update or Created
echo "Account Id". $AccountId ."<br/>";
$query="Select p.Id from PricebookEntry p where CurrencyIsoCode='".$currency."'";
echo $query;
$response = $mySforceConnection->query($query);
echo $response->records[0]->Id.'<br/>';
Select records
$query="Select p.Id from PricebookEntry p where CurrencyIsoCode='".$currency."'";
echo $query;
$response = $mySforceConnection->query($query);
echo $response->records[0]->Id.'<br/>';
No comments:
Post a Comment