This is my first attempt at creating a webhook endpoint, and I'm running into some issues. I'm sending a webhook from a JotForm to a php file on my server. The php is executing perfectly, but I also have some scripts in the file that reference an external script and run a function.
The end goal is to send the submission data from the jotform to our Marketo CRM using Marketo's API. However, the scripts in the endpoint don't seem to execute. This same script works perfectly if I set it up so the user actually hits a page with this script on it, but it doesn't work if I try to execute it through a webhook behind the scenes. Any idea what I'm missing? Here's the code in its entirety:
<?php
//Strips all slashes in an array
function stripslashes_deep($value){
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$result = stripslashes_deep($_REQUEST['rawRequest']);
//Convert json to php variable
$obj = json_decode($result, true);
//Initialize input variables
$theName = $obj['q1_name'];
$theEmail = $obj['q3_email'];
?>
<!----------------Marketo Munchkin API------------------------------>
<script src="http://munchkin.marketo.net/munchkin.js" type="text/javascript"></script>
<script>
mktoMunchkin("OUR_MARKETO_ID");
mktoMunchkinFunction(
'associateLead',
{
Email: <?php echo "decodeURIComponent(\"" . rawurlencode($theEmail) . "\")" ?>,
FirstName: <?php echo "decodeURIComponent(\"" . rawurlencode($theName) . "\")" ?>
},
'<?php echo hash('sha1', 'our-secret-key' . $theEmail); ?>'
);
</script>
<!---------------------------------------------------------------->
The "OUR_MARKETO_ID" and "our-secret-key" in the code contains our credentials.
Is there another way I should be executing the JS?