Welcome Guest, Not a member yet? Register   Sign In
Salesforce API Library - Rough Draft
#1

[eluser]Jay Logan[/eluser]
We started using Salesforce at my job and instead of building out apps using the Saleforce APEX language, I've been using CodeIgniter to build the app and sending data over to Salesforce through their API. It's been working like a charm. I'm sure there is plenty of room for improvement with the attached code but it will definitely give you a good start on working with their API. And the documentation on the link below will help you on the SF end too.

http://www.salesforce.com/us/developer/d...me=webhelp

Just drop the zipped filed into your library folder, load the library, then you can add data like this:

Code:
$this->load->library('salesforce');

$lead_info['OwnerID'] = "987234JHKJ22342";
$lead_info['Market_Assignment__c'] = "Atlanta GA";
$lead_info['Status'] = "Pending";
$lead_info['FirstName'] = $this->input->post('name_first');
$lead_info['LastName'] = $this->input->post('name_last');
$lead_info['Email'] = $this->input->post('email_home');
$lead_info['Phone'] = $this->input->post('phone_home');
$lead_info['Street'] = $this->input->post('addr_home_street');
$lead_info['City'] = $this->input->post('addr_home_city');
$lead_info['State'] = $this->input->post('addr_home_state');
$lead_info['PostalCode'] = $this->input->post('addr_home_zip');
    
$salesforce_lead_info = $this->salesforce->create('Lead', $lead_info);

And that will return the Salesforce response array. Enjoy.
#2

[eluser]onblur[/eluser]
Hey. Thanks for posting this. I'm looking at some CI and Integration and sure this will come in handy.

Greg.
#3

[eluser]naren_nag[/eluser]
This is very cool. We've just been asked to integrate with Salesforce! Will use and let you know.

Thanks,

Naren
#4

[eluser]BrandonDurham[/eluser]
I'm getting two errors when trying to use this code:
Code:
Severity: Notice
Message: Use of undefined constant SOAP_COMPRESSION_ACCEPT - assumed 'SOAP_COMPRESSION_ACCEPT'
Filename: soapclient/SforceBaseClient.php
Line Number: 102

Code:
Severity: Notice
Message: Use of undefined constant SOAP_COMPRESSION_GZIP - assumed 'SOAP_COMPRESSION_GZIP'
Filename: soapclient/SforceBaseClient.php
Line Number: 103

Any idea what the problem might be? I really appreciate any help I can get!
#5

[eluser]shaffick[/eluser]
Brandon, I might be too late, but I fixed it by installing soap on my web server (enable it in php.ini).

edit: also, API access is allowed by Enterprise, Unlimited and Developer edition

http://www.salesforce.com/crm/editions-pricing.jsp
#6

[eluser]shaffick[/eluser]
Edit: Works with CI 2.0.2. Tested. /edit

Here's another little rough, "hack" if I may (mostly because I was getting an error with __setSoapHeaders() )

add to Salesforce.php
Code:
function send_email($array_object)
{
    $emailResult = $this->mySforceConnection->sendSingleEmail($array_object);
    return $emailResult;
}

Usage:
Code:
$email = new SingleEmailMessage();
$email->setEmailPriority("Normal");
$email->setSaveAsActivity(true);
$email->setReplyTo($repInfo->Email);
$email->setUseSignature(false);
$email->setSubject($templateInfo->records[0]->Subject);

$repInfo->FullName = $repInfo->FirstName . " " . $repInfo->LastName;
$email->setSenderDisplayName($repInfo->FullName);
$email->setHtmlBody($emailHtml);
$email->setToAddresses($lead->lead_email);

//This is required so that Salesforce can save the email as activity
$email->setTargetObjectId($lead_info['Id']);

$emailSend = $this->salesforce->send_email(array($email));

Note: Emails will be sent as the email login you have in Salesforce.php Line 17.
Reply Address can be anything
#7

[eluser]Unknown[/eluser]
I am unable to download the zip.... Is there another place where this is located? This seems perfect for what I am doing...
#8

[eluser]jakelehner[/eluser]
I'm also having trouble accessing the attached file. Is there another place to obtain this library? Or another sales force API library?
#9

[eluser]Unknown[/eluser]
I'm having trouble downloading as well. I'm very interested to see this as I'm embarking on the same project.
#10

[eluser]Jason Hamilton-Mascioli[/eluser]
Try this thread... http://ellislab.com/forums/viewthread/212536/




Theme © iAndrew 2016 - Forum software by © MyBB