Error while using PHP API Wrapper

Hi, I am getting started with using activecampaign php api wrapper. I am using the example functions that is provided in github but when I am using it I get a error saying:
Fatal error: Cannot redeclare class ActiveCampaign in
I am using php codeigniter framework to get thie api working, here is a example on how its being used.
I am using codeigniter controller and a function to test the api. Here are the codes for the function with the class

     class Activecampaign extends CI_Controller {
    // protected root directory;
    protected $root;
        
    /**
     * Constructor that loads all necessary models
     */
    public function __construct()
    {
        parent::__construct();
        $this->load->model("localization");
 
        $this->root = dirname(dirname(dirname(__FILE__)));
        require_once $this->root . '/vendor/autoload.php';
       
    }
    
    public function initializeActiveCampaign(){
        
      require_once $this->root . '/vendor/activecampaign/api-php/includes/ActiveCampaign.class.php';
        $ac = new ActiveCampaign("url", "pass");

	if (!(int)$ac->credentials_test()) {
		echo "<p>Access denied: Invalid credentials (URL and/or API key).</p>";
		exit();
	}
    
        echo "<p>Credentials valid! Proceeding...</p>";

	/*
	 * VIEW ACCOUNT DETAILS.
	 */

	$account = $ac->api("account/view");

	echo "<pre>";
	print_r($account);
	echo "</pre>";
        
    }
    
}

The error if I remove require onces is that api is undefined, but its odd that there is a fatal error. Need help with this. Thanks

1 Like

Fixed the problem, there was the same class name of the controller I was using, stupid mistake.

Hey @auroraexchange,

glad everything is sorted out! We’re here if you need us.