使用PHP和API发送选定的字段数据';s

使用PHP和API发送选定的字段数据';s,php,forms,api,select,options,Php,Forms,Api,Select,Options,我正在使用API向第三方CRM数据库提交表单数据 这是表单的html <div class="column last"> <label for="role">What is your role?</label> <select name="role" id="role"> <option value="noresponse">Please select on

我正在使用API向第三方CRM数据库提交表单数据

这是表单的html

        <div class="column last">
          <label for="role">What is your role?</label>
          <select name="role" id="role">
            <option value="noresponse">Please select one</option>
            <option value="reseller">Reseller</option>
            <option value="researcher">Researcher</option>
            <option value="end-user">End-user</option>
            <option value="other">Other</option>
          </select>
        </div>

你的角色是什么?
请选择一个
转售商
研究员
最终用户
其他
下面是使用API发送所选字段数据的php

<?php
    //Process a new form submission in HubSpot in order to create a new Contact.
    $hubspotutk = $_COOKIE['hubspotutk'];  //grab the cookie from the visitors browser.
    $ip_addr = $_SERVER['REMOTE_ADDR'];  //IP address too.
    $hs_context = array(
            'hutk' => $hubspotutk,
            'ipAddress' => $ip_addr,
            'pageUrl' => 'http://www.suntechmed.com/index.php?option=com_chronoforms&chronoform=test_form',
            'pageName' => 'Test Form'
        );

    $hs_context_json = json_encode($hs_context);
    //Need to populate these varilables with values from the form.
    $str_post = "firstname=" . urlencode($_POST["firstname"])
                        . "&lastname=" . urlencode($_POST["lastname"])
                        . "&company=" . urlencode($_POST["company"])
            . "&role=" . urlencode($POST["role"])            
            . "&address=" . urlencode($_POST["address"])
            . "&city=" . urlencode($_POST["city"])
            . "&state=" . urlencode($_POST["state"])
            . "&zip=" . urlencode($_POST["zip"])
            . "&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/myHubspotID/b9752739-c9a3-4dc3-bf34-cb23679a41d4';
    $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;
    ?>

创建一个发送,并在php上编写自己的API。您可以通过以下操作添加用户:

($捐赠->订阅新闻通讯===true){ require_once('system/cm/csrest_subscribers.php')


你可以在它们的

上找到所有的php文件,甚至是一些例子。你在
$\u POST['role']
中漏掉了
\
。这个答案是不相关的。这个问题没有提到任何关于CreateSend/CampaignMonitor API的内容。我想肯定“答案是不相关的”如果用户思维短浅,很明显用户正在使用创建和发送api,答案中的第一件事是引用创建和发送api,因此不会误导阅读有困难的用户用户用户正在使用HubSpot api。您认为CreateSend在哪里提到?
    $wrap = new CS_REST_Subscribers(CS_REST_DONATE_LIST_ID, CS_REST_DONATE_API_KEY);
    $result = $wrap->add(array(
        'EmailAddress' => $donation->email,
        'Name' => sprintf('%s %s', $donation->first_name, $donation->last_name),
        'CustomFields' => array(),
        'Resubscribe' => true
    ));