Help with integration GF and LimeDB CRM #1

Closed
saneldesign opened this Issue Dec 11, 2013 · 7 comments

Projects

None yet

2 participants

@saneldesign

Hello

First - great plugin.
But...I am not so great, I am affraid ;(. PLease, can you help me with integration GF and LimeDB CRM using this plugin.

I really don't know what to do here. LimeDB support is horror! They sent me some kind documentation and some links but I dont get it, becouse I am not so familiar with SOAP and similar functionas.

Any help appreciate!

@zaus
Owner

I think we can start by altering the headers and the post body to send it as XML instead. Looking into it.

@zaus
Owner

First step is to try the branch https://github.com/zaus/forms-3rdparty-integration/tree/soap-headers.

Then add the following hook to your functions.php file (or wherever):

// bypass hook
add_filter('Forms3rdPartyIntegration_service_filter_args', array(&$this, 'limedb_send_soap'), 10, 3);

// the actual hook -- will send a soap request
function limedb_send_soap($args, $service, $form) {
    // if you only want this to occur for a specific service and/or form, filter here and return $args

    $result = array('request' => $args); // preserve the original request for debugging

    try {
        $client = new SoapClient($service['url']);

        // might need further customization to the post body rather than just passing the mapped form post
        $response = $client->ConsumeLead($args['body']);

        // using special hook bypass value
        $result['response_bypass'] =
            // turn response back into expected remote_post format
            array('body' => $response, 'response' => array('code'=>200));

    } catch (Exception $e) {
        $result['response_bypass'] = array(
            'response' => array(
                'code' => 500
                , 'message' => $e->getMessage()
                )
            );
    }

    return $result;
}
@zaus
Owner

And if it wasn't clear from the previous comment, you should hopefully only need to change the line:

$response = $client->ConsumeLead($args['body']);
@saneldesign
@zaus
Owner

The branch is now live, btw.

You'll need to:
1) update the plugin
2) write a hook to take advantage of the new ability to transform the post body and bypass the original form-post
3) the hook will instead generate a SOAP request, which you'll need to format per the LimeDB specs
4) since you're now performing the "post" in the hook, the hook will return the special array (response_bypass) that tells my plugin to skip sending the form post as usual

@zaus
Owner

We can follow up on LimeDB specifics via email.

@zaus zaus closed this Dec 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment