We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

extension development - Salesforce data push

Development and Programming

liquidbook's avatar
liquidbook
1 posts
17 years ago
liquidbook's avatar liquidbook

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 😊

       
George Ornbo's avatar
George Ornbo
272 posts
17 years ago
George Ornbo's avatar George Ornbo

I have a client who has asked me for that just today. Did you get any further with it?

       
ira42's avatar
ira42
167 posts
17 years ago
ira42's avatar ira42

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!

       
George Ornbo's avatar
George Ornbo
272 posts
17 years ago
George Ornbo's avatar George Ornbo

I think CURL is probably the best route. I need it to go into ListMailPro AND Salesforce. I will be starting development on this tomorrow I think.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

Let us know how it goes. I have similar plans for Freshbooks.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

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.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

Andy, here’s the Freshbooks API. It’s really quite straight forward XML.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Thanks Ingmar!

       
George Ornbo's avatar
George Ornbo
272 posts
17 years ago
George Ornbo's avatar George Ornbo

I’m just about there on this one. I’m using cURL (available on most environments) to push the data to the forms. Seems to work pretty well so far - just sorting out an issue with registration.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

Would you mind sharing a few details? I have not really tried hard, but sticking the sample code in an EE template did not work.

       
George Ornbo's avatar
George Ornbo
272 posts
17 years ago
George Ornbo's avatar George Ornbo

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.

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

Salesforce seems to have an excellent PHP Toolkit. Is this worth investigating?

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Would be interested to know how everyone got on with this. Aclient of ours is after the very same, the ability to push data from a form in EE (Freeform in this case) to Salesforce.com.

       
james Brown's avatar
james Brown
492 posts
16 years ago
james Brown's avatar james Brown

I have the same needs as nathan. SalesForce with Freeform integration.

       
mmcclung's avatar
mmcclung
172 posts
16 years ago
mmcclung's avatar mmcclung

<bump>

Ditto

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.