Method AddLead and Create Task for Leads.
Get Salesforce developer account to.
http://developer.force.com
Source Code
<?php
/**
* Name : Salesforce - AddLead and Task API Webservice
* Description : Salesforce Webservice API Integration using PHP SOAP Client library.
* Author : Ryan Tipones
* Version : 0.1
* Author URI : wpmigrator.wordpress.com
* Salesforce Developer : http://developer.force.com/
*
*/
ini_set("soap.wsdl_cache_enabled", "0");
require_once 'soapclient/SforcePartnerClient.php';
require_once 'soapclient/SforceHeaderOptions.php';
$wsdl = 'soapclient/partner.wsdl.xml';
$userName = "YOUR_SALES_FORCE_USERNAME";
$password = "YOUR_SALES_FORCE_PASSWORD";
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$client->login($userName, $password);
/* Salesforce Create New Lead */
$lead = new sObject();
$lead->type = 'Lead';
$lead->fields = array(
'FirstName' => '',
'LastName' => '',
'Company' => '',
'Email' => '',
'Country' => '',
'MobilePhone' => ''
);
/* Submitting the Lead to Salesforce */
$result = $client->create(array($lead), 'Lead');
/* Debug */
print_r($response);
/* Salesforce Create Task */
/* Check Lead Email if Exist*/
$response = $client->query("SELECT Id,Email from Lead WHERE Email='{$email}'");
if(!empty($response->records)){
$data = (array) $response->records;
$LeadId = $data[0]->Id;
$fields = array (
'Status' => '', // Not Started , In Progress , Completed
'Description' => '',
'Subject' => '',
'WhoId' => $LeadId,
'ActivityDate' => date('c')
);
$sObject = new SObject();
$sObject->fields = $fields;
$sObject->type = 'Task';
$response = $client->create(array($sObject));
/* Debug */
print_r($response);
}
No comments:
Post a Comment