• Resolved Nick Verwymeren

    (@greatwitenorth)


    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)
  • Plugin Author Jack Arturo

    (@verygoodplugins)

    Ah yup, good catch. Didn’t realize they’d changed that!

    So, it looks like custom objects are out of beta, and we don’t need to use a separate API key at all ??

    *However*, WP Fusion requires additional scopes to do that.

    We’ll have an update out for the Lite plugin next week. When you install that update you’ll need to click Authorize With HubSpot one time from the Setup tab, and that will grant the additional crm.objects.custom.read, and crm.objects.custom.write permissions, and then WPF will be able to read and write to your custom objects on its own… you won’t need a separate key or private app ??

    Thread Starter Nick Verwymeren

    (@greatwitenorth)

    Great! Thanks for the quick fix!!

    Plugin Author Jack Arturo

    (@verygoodplugins)

    Ok that update is out now, once you update, click Reauthorize with HubSpot one time and that will grant the new scopes ????

    Thread Starter Nick Verwymeren

    (@greatwitenorth)

    Perfect! Thanks for the quick fix!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom object functions not working for Hubspot’ is closed to new replies.