因此,我正在考虑使用Pardot并使用cURL请求提交表单,但我在提交时遇到了一些问题。
假设Pardot提供的iFrame运行良好,如下所示:
<iframe src="https://go.test.com/l/926923/2022-05-25/3l5rr" width="100%" height="500" type="text/html" frameborder="0" allowTransparency="true" style="border: 0"></iframe>
在Pardot上,我有以下表单字段:
enter image description here
现在,我尝试使用cURL
请求来执行测试提交,而不是iFrame,以便Pardot数据可以显示在“Prospects(Submissions)”中,使用以下代码:
$curl = curl_init();
curl_setopt(
$curl,
CURLOPT_URL,
'https://go.test.com/l/926923/2022-05-25/3l5rr'
);
curl_setopt(
$curl,
CURLOPT_POST,
true
);
curl_setopt(
$curl,
CURLOPT_POSTFIELDS,
[
'email' => 'joe@jonas.com',
'inquiry' => 'General',
'office_name' => 'Corporate Office',
'first_name' => 'Joe',
'last_name' => 'Jonas',
'message' => 'Test',
]
);
curl_setopt(
$curl,
CURLOPT_RETURNTRANSFER,
true
);
$result = curl_exec($curl);
error_log(print_r($result, true));
curl_close($curl);
由于某种原因,当cURL请求运行时,什么也没有发生-有人知道如何正确地执行cURL请求来调用POST以提交Pardot表单吗?
以下是错误响应:
[26-May-2022 19:48:31 UTC] <!DOCTYPE html>
<html>
<head>
<base href="https://go.fleishmanhillard.com" >
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="description" content=""/>
<title></title>
<script type="text/javascript" src="https://go.test.com/js/piUtils.js?ver=2021-09-20"></script><script type="text/javascript">
piAId = '927923';
piCId = '42983';
piHostname = 'pi.pardot.com';
if(!window['pi']) { window['pi'] = {}; } pi = window['pi']; if(!pi['tracker']) { pi['tracker'] = {}; } pi.tracker.pi_form = true;
(function() {
function async_load(){
var s = document.createElement('script'); s.type = 'text/javascript';
s.src = ('https:' == document.location.protocol ? 'https://pi' : 'http://cdn') + '.pardot.com/pd.js';
var c = document.getElementsByTagName('script')[0]; c.parentNode.insertBefore(s, c);
}
if(window.attachEvent) { window.attachEvent('onload', async_load); }
else { window.addEventListener('load', async_load, false); }
})();
</script></head>
<body>
<form accept-charset="UTF-8" method="post" action="https://go.test.com/l/926923/2022-05-25/3l5rr" class="form" id="pardot-form">
<p class="errors">Please correct the errors below:</p>
<p class="form-field Type pd-select required error ">
<label class="field-label" for="926923_56599pi_926923_56599">Type of Inquiry</label>
<select name="926923_56599pi_926923_56599" id="926923_56599pi_926923_56599" class="select" onchange=""><option value="" selected="selected"></option>
<option value="1016038">New Business</option>
<option value="1016041">Crisis Management</option>
<option value="1016044">Media</option>
<option value="1016047">General</option>
<option value="1016050">Careers</option>
</select>
</p>
<div id="error_for_926923_56599pi_926923_56599" style="display:none"></div>
<p class="error no-label">This field is required</p>
<p class="form-field email pd-text required error ">
<label class="field-label" for="926923_56554pi_926923_56554">Email</label>
<input type="text" name="926923_56554pi_926923_56554" id="926923_56554pi_926923_56554" value="" class="text" size="30" maxlength="255" onchange="" onfocus="" />
</p>
<div id="error_for_926923_56554pi_926923_56554" style="display:none"></div>
<p class="error no-label">This field is required.</p>
<p class="form-field first_name pd-text required error ">
<label class="field-label" for="926923_56545pi_926923_56545">First Name</label>
<input type="text" name="926923_56545pi_926923_56545" id="926923_56545pi_926923_56545" value="" class="text" size="30" maxlength="40" onchange="" onfocus="" />
</p>
<div id="error_for_926923_56545pi_926923_56545" style="display:none"></div>
<p class="error no-label">This field is required.</p>
<p class="form-field last_name pd-text required error ">
<label class="field-label" for="926923_56548pi_926923_56548">Last Name</label>
<input type="text" name="926923_56548pi_926923_56548" id="926923_56548pi_926923_56548" value="" class="text" size="30" maxlength="80" onchange="" onfocus="" />
</p>
<div id="error_for_926923_56548pi_926923_56548" style="display:none"></div>
<p class="error no-label">This field is required.</p>
<p class="form-field company pd-text ">
<label class="field-label" for="926923_56551pi_926923_56551">Company</label>
<input type="text" name="926923_56551pi_926923_56551" id="926923_56551pi_926923_56551" value="" class="text" size="30" maxlength="255" onchange="" onfocus="" />
</p>
<div id="error_for_926923_56551pi_926923_56551" style="display:none"></div>
<p style="position:absolute; width:190px; left:-9999px; top: -9999px;visibility:hidden;">
<label for="pi_extra_field">Comments</label>
<input type="text" name="pi_extra_field" id="pi_extra_field"/>
</p>
<!-- forces IE5-8 to correctly submit UTF8 content -->
<input name="_utf8" type="hidden" value="☃" />
<p class="submit">
<input type="submit" accesskey="s" value="" />
</p>
<script type="text/javascript">
//<![CDATA[
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if(anchor.getAttribute("href")&&!anchor.getAttribute("target")) {
anchor.target = "_top";
}
}
//]]>
</script>
<input type="hidden" name="hiddenDependentFields" id="hiddenDependentFields" value="" /></form>
<script type="text/javascript">(function(){ pardot.$(document).ready(function(){ (function() {
var $ = window.pardot.$;
window.pardot.FormDependencyMap = [];
$('.form-field-primary input, .form-field-primary select').each(function(index, input) {
$(input).on('change', window.piAjax.checkForDependentField);
window.piAjax.checkForDependentField.call(input);
});
})(); });})();</script>
</body>
</html>
1条答案
按热度按时间5lhxktic1#
Pardot表单字段名本质上是数字,很坚韧编写脚本。
如果可能的话,看看Pardot表单处理程序(只是表单的后端),它们非常适合脚本编写/集成,因为它们简单得多,并且允许您定义字段名。
如果您需要使用表单(用于表单的实际测试,而不是用于接收数据),则需要将有效负载的字段名称替换为表单上的名称。对于选择列表,您将具有:
926923_56599pi_926923_56599
=1016038
(对于新业务)。此外,请确保您的值是application/x-www-url-encoded。