Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

MP_Addon_Hubspot::send_hubspot( array $data )

Send multiple sending to Hubspot.


Parameters Parameters

$data

(array) (Required) lead IDs


Top ↑

Source Source

File: calculator-hubspot-add-on/inc/MP_Addon_Hubspot.php

    private function send_hubspot($data)
    {
        $data = $this->prepare_multiple_data($data);

        if (! empty($data)) {
            $url = "https://api.hubapi.com/contacts/v1/contact/batch/?hapikey=" . $this->api_key;

            $response = wp_remote_post($url, array(
                'timeout'     => 30,
                'redirection' => 10,
                'httpversion' => '1.1',
                'headers'     =>array('Content-Type' => 'application/json; charset=utf-8'),
                'body'        => json_encode($data),
            ));

            $response_code = wp_remote_retrieve_response_code($response);
            $result = json_decode($response['body'], 1);

            if (200 === $response_code) {
                echo esc_html__('Ready', 'CalculatorsHubspotAddon');
            } else {
                echo wp_remote_retrieve_response_message($response);
            }
        } else {
            echo esc_html__('No lead selected', 'CalculatorsHubspotAddon');
        }
    }

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.