• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How to submit form data to 3rd party REST API service

New Here ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

Hi Guys,

This is new to me, so any sample scripts and procedures will be appreciated.

Problem:

My client has opted for a more advanced 3rd party CRM solution which uses REST API

They want form data captured (Contact us form) and submitted to the 3rd party CRM

The CRM API sample scripts available are PHP and makes no sense to me.

This is their sample form and php script.

Questions:

1) How do I convert this to work in BC

2) Is it possible to use Liquid as a server side script to do API calls?

3) Also would like to hide the API user name and token?

Samples:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <style type="text/css">

      label, input, textarea { display: block; float: left; width: 150px; margin: 5px; }

      label { clear: left; text-align: right; }

      input[type="submit"] { width: 60px; margin: 10px 0 0 165px; clear: left; }

    </style>

  </head>

  <body>

    <h2>Contact Us</h2>

    <!-- REQUIRED Edit with the filename of the script if different than the example -->

    <form action="Solve360ContactSave.php" method="GET">

      <label>First name (required)</label>

      <input type="text" name="firstname" value="" />

      <label>Last Name</label>

      <input type="text" name="lastname" value="" />

      <label>Job title</label>

      <input type="text" name="jobtitle" value="" />

      <label>Business email</label>

      <input type="text" name="businessemail" value="" />

      <label>Note</label>

      <textarea name="note" cols="4" rows="4"></textarea>

      <input type="submit" value="Save" />

    </form>

  </body>

</html>

PHP:

<?php

    // version 2.0

    // All placeholders such as {ownership}, {categoryId}, {templateId} should

    // be replaced with real values without the {} brackets

    // REQUIRED Edit with your email address

    define('USER', 'xxxxxxxx@xxxxxxxx.com');

    // REQUIRED Edit with token, Workspace > My Account > API Reference > API Token

    define('TOKEN', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); 

    // Get request data

    $requestData = array();

    parse_str($_SERVER['QUERY_STRING'], $requestData);

    // Configure service gateway object

    require 'Solve360Service.php';

    $solve360Service = new Solve360Service(USER, TOKEN);

    //

    // Adding the contact

    //

    $contactData = array(

        'firstname'     => $requestData['firstname'],

        'lastname'      => $requestData['lastname'],

        'jobtitle'      => $requestData['jobtitle'],

        'businessemail' => $requestData['businessemail'],

        // OPTION Apply category tag(s) and set the owner for the contact to a group

        // You will find a list of IDs for your tags, groups and users in Workspace > My Account > API Reference

        // To enable this option, uncomment the following:

        /*       

        // Specify a different ownership i.e. share the item

        'ownership'     => {ownership},

        // Add categories

        'categories'    => array(

            'add' => array('category' => array({categoryId},{categoryId}))

        ),

        */       

       

    );

   

    $contact = $solve360Service->addContact($contactData);

   

    if (isset($contact->errors)) {

        // Mail yourself if errors occur 

        mail(

            USER,

            'Error while adding contact to Solve',

            'Error: ' . $contact->errors->asXml()

        );

        die ('System error');

    } else {

        // Get new contact params from the response

        $contactName = (string) $contact->item->name;

        $contactId   = (integer) $contact->item->id;

       

        // Mail yourself the result

        mail(

            USER,

            'New contact added to Solve',

            'New contact "' . $contactName . '" with id ' . $contactId . ' was added to Solve360'

        );

    }

   

    //

    // OPTION Adding a activity

    //

   

    /*

     * You can attach an activity to the contact you just created

     * This example creates a Note, to enable this feature just uncomment the following request

     */   

   

    /*   

    // Preparing data for the note

    $noteData = array(

        'details' => nl2br($requestData['note'])

    );

    $note = $solve360Service->addActivity($contactId, 'note', $noteData);

   

    // Mail yourself the result

    mail(

        USER,

        'Note was added to "' . $contactName . '" contact in Solve',

        'Note with id ' . $note->id . ' was added to the contact with id ' . $contactId

    );

    // End of adding note activity

    */

    //

    // OPTION Inserting a template of activities

    //

   

    /*

     * You can also insert a template directly into the contact you just created

     * You will find a list of IDs for your templates in Workspace > My Account > API Reference

     * To enable this feature just uncomment the following request

     */

    /*

    // Start of template request

    $templateId = {templateId};

    $template = $solve360Service->addActivity($contactId, 'template', array('templateid' => $templateId));

       

    // Mail yourself the result

    mail(

        USER,

        'Template was added to "' . $contactName . '" contact in Solve',

        'Template with id ' . $templateId . ' was added to the contact with id ' . $contactId

    );

    // End of template request

    */

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    </head>

    <body>

        <h2>Result</h2>

        <p>Thank you, <b><?php echo $contactName ?></b></p>

        <p>Your data was successfully saved.</p>

    </body>

</html>

TOPICS
3rd party integration

Views

6.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 18, 2016 May 18, 2016

You can not use liquid or host server side code on BC to do that.

You either need to have a form setup to point to a 3rd party solution that submits data into them or you need to implement and API to API solution.
A form will create a case (or order if taking payment) and you can have the BC API send to a url the notification when cases are fired. With your own code solution you would read the cases, get the ones for the form you want and send the information to the 3rd party in the data structure

...

Votes

Translate

Translate
LEGEND ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

You can not use liquid or host server side code on BC to do that.

You either need to have a form setup to point to a 3rd party solution that submits data into them or you need to implement and API to API solution.
A form will create a case (or order if taking payment) and you can have the BC API send to a url the notification when cases are fired. With your own code solution you would read the cases, get the ones for the form you want and send the information to the 3rd party in the data structure they require.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2016 May 18, 2016

Copy link to clipboard

Copied

Thanks Liam,

I expected that to be the case, but had to ask.

Will use Wufoo forms as an alternative.

Thanks

Marius

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

But these would not go to a 3rd party in a detailed way your looking for and then wont get captured into your CRM of your site. That sounds like a worse option for you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

Hi Liam,

I have done tests today from a WuFoo form contained inside a BC page and it works fine.

They provide full html code with a jquery script for this purpose.

The form data collected is stored at WuFoo and then retrieved by the CRM service.

The CRM service in this case (Solve360) connects to WuFoo via REST API and pulls down the data.

The time for the data to appear in the CRM was less than 2 seconds and works perfectly every time.

Anyone with a similar requirement should investigate WuFoo forms.

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2016 May 19, 2016

Copy link to clipboard

Copied

But like I said, then nothing is stored in BC so you can not use the email Marketing feature, manage any possible orders, case workflow or anything like that. So quite a bit of wastage there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 13, 2016 Jun 13, 2016

Copy link to clipboard

Copied

> or you need to implement and API to API solution.

Liam, can you provide some detail or documentation on how to do an API-to-API solution?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 13, 2016 Jun 13, 2016

Copy link to clipboard

Copied

Best to read the documentation:
Getting started with the BC APIs

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 13, 2016 Jun 13, 2016

Copy link to clipboard

Copied

Those APIs seem to be client-side, dealing with calling into BC, is that correct?  What I need to happen is for a form submit to trigger a POST to a third party containing some values from the form and API auth secrets that can't be exposed to the client-side.  Is this possible with BC?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 13, 2016 Jun 13, 2016

Copy link to clipboard

Copied

No, It also covers the SOAP API in there.

There is no Form Data API.

Forms create cases, Cases can be read to the API.

In the admin - Settings - API you will see the 3 fields to enter notification urls for your 3rd party API when events happen. One of those is for cases so when a case is made (from forms) you can recieve and handle them.

Case_Retrieve | Business Catalyst Support

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

Thanks for your help.  I apologize for my ignorance, I'm trying to integrate my API with a client's BC account and this is my first exposure to BC.

In the API section, I don't see "Cases":

====

API Integration Settings

====

Is it just named differently in one of those options above? 

EDIT:  "Customer Inquiries" is the one that works, however, the only data that it posts to your url is an "ObjectType" and an "ObjectID".  The ObjectID corresponds to the Case ID. 

Now the task is to figure out how to send a custom POST to the third-party API using the actual form data, because the third-party is not going to call back into BC to look up details on the Case ID (think Twilio)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

If you look at my post above I liked how you retrieve the case.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 18, 2016 Jul 18, 2016

Copy link to clipboard

Copied

LATEST

Also has a follow up to my comment. There is now form API released since this was posted.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 18, 2016 Jul 18, 2016

Copy link to clipboard

Copied

@SmilingGoat: A little late to the party. 99% of CRM's are surly going to allow a standard HTTP POST as input? For example if you hosted your HTML externally you could post the data to their CRM? I think you are thinking a little too much into this with the API, you should attempt to double POST the data. I've done this for several external CRM's including marketo, sales force and another one I can't remember off the top of my head without issue. Point being, it should make for a much easier implementation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 18, 2016 Jul 18, 2016

Copy link to clipboard

Copied

Depends on if you want to validate or process the data during, before or after though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines