Process lead data with JavaScript after form submission and before Webhook | Community
Skip to main content
January 15, 2013
Duplicate

Process lead data with JavaScript after form submission and before Webhook

  • January 15, 2013
  • 7 replies
  • 3266 views

 

I'm using a WebHook to post lead info to an external RESTful API upon successful form submission.  This works perfectly...almost.
 
Because RESTful APIs are URL-based, the information is assumed be come through as URL-encoded.  Certain characters have different meaning when URL-encoded.  For example "+" means a blank space.  Some users filling out my form have legitamate "+" in their emali address (e.g. "name+last@email.com"), which are getting interperted as blank spaces by the 3rd party app (e.g. "name last@email.com").
 
I would like a way to process the lead data before it makes it to the Webhook. Basically, I'd like to pass the webhook template a version of lead.Email Address that has been passed through javascript's encodeURIComponent function.
 
I hope this is clear, and that there's an answer to this.
 
thanks,
Mark

7 replies

New Participant
February 24, 2020
No text available
January 18, 2013
No, the "Sent" thing is just for debugging when I visit it through a web-browser. Not needed at all.

Not sure why the webhook isn't calling your webserivce though.
January 18, 2013
I'm still stumped as to why my perfectly working PHP script works when accessed via web browsers doesn't seem to be getting hit my a WebHook that's associated with a valid trigger.

I see Erik's wrapper script returned "Sent"  Is that a requirement?
January 17, 2013
Great tip.  Thanks!  

So I've written PHP script that defnitely works standalone at cleaning up $_POST data and calling the API in question (yay), but it doesn't seem to be getting hit by the webhook (boo!).

Any ideas?

--mark


January 16, 2013
Well, actually I meant using a webhook to call PHP which then did custom encoding and then called the API. As an example, here is how I was calling Twillio's SMS API:

<?php
require "Services/Twilio.php";
 
$AccountSid = "xxx";
$AuthToken = "xxx";
 
$client = new Services_Twilio($AccountSid, $AuthToken);
$from = 'xxx';
 
try {
$client->account->sms_messages->create($from, $_POST["number"], $_POST["message"]);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
echo "Sent";
?>

Instead of just passing in the details POST'ed in, you could encode them in some other way first.
January 16, 2013
Thanks, Erik.

So, perhaps Webhooks aren't right for this task.  

As a starting point for a PHP wrapper, would you recomend this Marketo Form Proxy v1.1.0?  Somethhing else?

--mark
January 15, 2013
One thing I do right now in these cases is write a very simple PHP wrapper around my function that handles the encoding the way I want. Not quite as elegant as having Marketo do it, but usually a lightweight solution.