Custom object functions not working for Hubspot
-
I tried loading a custom object from Hubspot using this plugin but received an error about invalid API credentials (they were correct). It looks like Hubspot no longer supports using hapikey. The problematic code can be found on line 1116 of wp-content/plugins/wp-fusion-lite/includes/crms/hubspot/class-hubspot.php.
I re-wrote the code and came up with this possible solution:
public function load_object( $object_id, $object_type_id, $properties ) { if ( ! defined( 'HUBSPOT_API_KEY' ) ) { return new WP_Error( 'error', 'HubSpot API key not defined. See https://wpfusion.com/documentation/crm-specific-docs/hubspot-custom-objects/' ); } $params = $this->get_params(); $params['headers']['Authorization'] = "Bearer " . HUBSPOT_API_KEY; $request = 'https://api.hubapi.com/crm/v3/objects/' . $object_type_id . '/' . $object_id . '/?properties=' . urlencode(implode(',', $properties)); $response = wp_safe_remote_get( $request, $params ); if ( is_wp_error( $response ) ) { return $response; } $response = json_decode( wp_remote_retrieve_body( $response ), true ); return $response; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom object functions not working for Hubspot’ is closed to new replies.