I am new to development for EE. I need to develop an extension so that I can take the new member registration information and push the data to salesforce.com. Here is the process. I take the data from an array and map it a Salesforce array structure.
$pData['first_name'] = $myData['first_name'];
$pData['last_name'] = $myData['last_name'];
$pData['company'] = $myData['company'];
$pData['title'] = $myData['title'];
$pData['email'] = $myData['email'];
$pData['phone'] = $myData['phone'];
$pData['street'] = $myData['street'];
$pData['city'] = $myData['city'];
$pData['state'] = $myData['state'];
$pData['zip'] = $myData['zip'];
$pData['country'] = $myData['country'];
Then I take $pData and push it to salesforce using php’s curl method to push data.
I have started an extension shell, but thats where i get a little foggy. here is my start
<?php
if ( ! defined('EXT'))
{
exit('Invalid file request');
}
class sf_push
{
var $settings = array();
var $name = 'Salesforce WebToLead';
var $version = '1.0';
var $description = 'An extension for pushing data to a salesforce account';
var $settings_exist = 'n';
var $docs_url = '';//'liquidbook.com';
// -------------------------------
// Constructor - Extensions use this for settings
// -------------------------------
function sf_push($settings='')
{
$this->settings = $settings;
}
// END
// --------------------------------
// Activate Extension
// --------------------------------
function activate_extension()
{
global $DB;
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => "sf_push",
'method' => "push_data",
'hook' => "member_member_register",
'settings' => "",
'priority' => 10,
'version' => $this->version,
'enabled' => "y"
)
)
);
}
// END
// --------------------------------
// Disable Extension
// --------------------------------
function disable_extension()
{
global $DB;
$DB->query("DELETE FROM exp_extensions WHERE class = 'sf_push'");
}
// END
// --------------------------------
// Push Data
// --------------------------------
function push_data()
{
global $EXT;
$edata = $EXT->call_extension('member_member_register');
//
// data push code to go here
// pushing items from the array $edata
//
if ($EXT->end_script === TRUE) return;
}
// END
}
?>
First I can’t seem to get the extension to be seen by the EE (1.5.2), while other extensions can be added. I tried Derek Jones Register Birthday extension that worked fine. I know the extension is being read by EE because if there is a syntax error it will report the error. Also I don’t see any trailing or preceding white space.
I am not sure that the “member_member_register” is the right hook. Is there a way to test the array structure like print_r($eData). I only want to push the data once during the registration process. writing data push part of the program i can do fine.
Any insights or help with this would be greatly appreciated. Thanks 😊
Curious to know if either of you had any luck with this? I have a client who needs this functionality as well.
I’ve been mucking about trying to use ajax form calls to submit the form twice, once for the registration, and once for the Salsforce web-to-lead, but this stuff is way over my head…
Would love to see an extension for this!
This can be done - in fact I’ve done it - but I’m trying to create a semi-generic registration EXT, that will handle most or at least some of the available 3rd party services.
I would greatly appreciate if those of you who would benefit from this kind of EXT could post the url to the service for which you need this EXT - AND how this particular service wants registrations sent to them, direct links to API’s are great.
Also, please post any additional details you can think of, it will be most helpful in deciding if this is a worthwhile project.
Shape Shed: ListMailPro, Salesforce noted. (dual registrations, huh? - neat, I’ll see about that) Ingmar: Freshbooks noted.
edit: grammar, oh the grammar.
The extension isn’t quite ready for release yet but I’ve a written an extension to take over at the hook “member_member_register”.
The code that does the work is as follows:
/*
========================================================================
Send user information to Sales Force
========================================================================
*/
// Specify the URL for the POST Data to go to
$url="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
// Initiate cURL (this must be compiled on the server)
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
// Set the POST fields
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'oid=xxxx&first;_name='.urlencode(utf8_encode($_POST['screen_name'])).'&last;_name='.urlencode(utf8_encode($_POST['screen_name'])).'&email;='.urlencode(utf8_encode($_POST['email'])).'&company;='.urlencode(utf8_encode($cust_fields['m_field_id_3'])).'&city=London&state=GreaterLondon&lead_source=Website&street=Mystreet&phone=1234567&mobile=07971604841');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec ($ch) # This returns HTML
curl_close ($ch);
You’ll see I’m still debugging in the code above and I will put some filtering on the POST data. The form submits fine though. oid is the Saleforce account number. I can’t get custom fields working at the moment either.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.