【问题标题】:How to create a prospect in hubspot using the Form API?如何使用 Form API 在 hubspot 中创建潜在客户?
【发布时间】:2014-04-18 12:04:17
【问题描述】:

我正在尝试通过提交表单在 hubspot 中创建潜在客户。 以下是我写的代码。

<?php
    function send_lead() {
    $hubspotutk = $_COOKIE['hubspotutk'];
    $ip_addr = $_SERVER['REMOTE_ADDR'];
    $hs_context = array(
        "hutk" => $hubstoputk,
        'ipAddress' => $ip_addr,
         'pageName' => 'Test Form'
       );

    $hs_context_json = json_encode($hs_context);
    //Need to populate these varilables with values from the form.
    $str_post ="email=" . urlencode($_POST["email"])
                    . "&hs_context=" . urlencode($hs_context_json);  //Leave this one be :)'

    //replace the values in this URL with your portal ID and your form GUID
    $endpoint = 'https://forms.hubspot.com/uploads/form/v2/portal-id/form-id';
    $ch = @curl_init();
    @curl_setopt($ch, CURLOPT_POST, true);
    @curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
    @curl_setopt($ch, CURLOPT_URL, $endpoint);
    @curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = @curl_exec($ch);  //Log the response from HubSpot as needed.
    @curl_close($ch);
    echo $response;

}
?>

我得到一个空的回复。谁能告诉我我的代码有什么问题?

【问题讨论】:

    标签: hubspot


    【解决方案1】:

    表单提交成功后,从 Hubspot 收到 204 响应。 204 是没有内容的响应。

    Hubspot 表单 api 参考可以在这里找到:http://developers.hubspot.com/docs/methods/forms/submit_form

    【讨论】:

      【解决方案2】:

      变量名的拼写错误。在$hs_context 数组中使用$hubspotutk。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-08-16
        • 2017-05-04
        • 1970-01-01
        • 2019-06-16
        • 1970-01-01
        • 2017-04-21
        相关资源
        最近更新 更多