使用卷曲请求提交pardot表格

发布于 2025-02-01 13:59:53 字数 7683 浏览 2 评论 0原文

因此,我正在研究使用pardot并使用卷曲请求提交表格,但是我在提交中遇到了一些问题。

因此,假设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上,我有以下表单字段:


​在“潜在客户(提交)”中使用以下方式:

$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' => '[email protected]',
        '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请求以调用帖子以提交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="&#9731;" />

        <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>

So I am looking into utilizing Pardot and submitting a form using a cURL request, but I'm having some issues with the submission.

So let's say the iFrame that Pardot provides works well and it looks like this:

<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>

Then on Pardot, I have the following form fields:

enter image description here


Now, I am trying to use a cURL request to execute a test submission instead of a iFrame so that Pardot data can show up in the "Prospects (Submissions)" using this:

$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' => '[email protected]',
        '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);

For some reason, when the cURL request runs, nothing happens - Does someone know how to properly execute a cURL request to call a POST to submit a Pardot form?


This is the error response:

[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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浊酒尽余欢 2025-02-08 13:59:53

pardot表格字段名称本质上是数字,很难脚本。

如果可能的话,请查看pardot表格处理程序(这只是形式的后端)。这些非常适合与脚本 /集成在一起,因为它们要简单得多,并且允许您定义字段名称。

如果您需要使用表单(用于表格的实际测试,而不是用于摄入数据),则需要用表单上的名称替换有效负载的字段名称。 SOR为您的选择列表,您将拥有:
926923_56599PI_926923_56599 = 1016038新业务。

另外,请确保您的值是应用程序/X-WWW-url编码。

Pardot Form field names are numeric in nature and quite tough to script.

If possible, take a look at Pardot Form Handlers (which are just a back-end of a Form). Those are ideal for scripting / integrating with as they are a lot simpler and allow you to define the field name.

If you need to use the form (for actual testing of the form, and not for ingesting data) you will need to replace your payload's field names with the names on the form. Sor for your picklist, you would have:
926923_56599pi_926923_56599 = 1016038 for New Business.

Also, be sure that your values are application/x-www-url-encoded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文