api-library icon indicating copy to clipboard operation
api-library copied to clipboard

I get Class 'Mautic\\Auth\\ApiAuth' not found since updated

Open miquelangeld opened this issue 3 years ago • 1 comments

Since we updated to the current Mautic Version 4.2.0 I get this error:

Uncaught Error: Class 'Mautic\\Auth\\ApiAuth' not found

I created a new server from the scratch and I get the same error. We did this conector, which worked fine until now:

<?php
  include 'vendor/autoload.php';
  use Mautic\Auth\ApiAuth;
  use Mautic\MauticApi;
//define function name  

  session_start();

  $settings = array(
      'userName'         => 'user',
      'password'         => 'pass',
  );

  $initAuth   = new ApiAuth();
  $auth       = $initAuth->newAuth($settings, 'BasicAuth');

  try{
    if ($auth) {
      $api        = new MauticApi();
      $contactApi = $api->newApi("contacts", $auth, 'https://mautic/api/');
      file_put_contents('conector.log', 'REQUEST: '.print_r($_REQUEST,true),FILE_APPEND);
            if($_REQUEST['action'] == "new"){
                $firstname = $_REQUEST['firstname'];
                $lastname = $_REQUEST['lastname'];
                $email = $_REQUEST['email'];
                $company = $_REQUEST['company'];
                $country = $_REQUEST['country'];
                $preferred_locale = strtolower($_REQUEST['preferred_locale']);
                $birthdate = $_REQUEST['birthdate'];
                $gender = $_REQUEST['gender'];
                $crm_source = $_REQUEST['crm_source'];

       $data = array(
        'firstname'     =>      $firstname,
        'lastname'      =>      $lastname,
        'email'     =>  $email,
        'company'       =>      $company,
        'country'       =>      $country,
        'preferred_locale'      =>      $preferred_locale,
        'birthdate'      =>      $birthdate,
        'gender'        =>      $gender,
        'crm_source'    =>      $crm_source
        );


        $contact = $contactApi->create($data);

        file_put_contents('conector.log', 'CONTACT API '.print_r($contact,true),FILE_APPEND | LOCK_EX);
        $idcontacto = $contact['contact']['id'];
 }else if($_REQUEST['action'] == "delete"){
        $contact = $contactApi->delete($_REQUEST['idContact']);
      }

    } else {
                echo "Error!";
    }
  } catch (Exception $e) {
        echo "Mautic not connected!";
  }
?>


<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://app.bountysource.com/issues/108499070-i-get-class-mautic-auth-apiauth-not-found-since-updated?utm_campaign=plugin&utm_content=tracker%2F10940535&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://app.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10940535&utm_medium=issues&utm_source=github).
</bountysource-plugin>

miquelangeld avatar Mar 10 '22 15:03 miquelangeld

How did you install the library? It looks like it missing from the autoload.php or from vendor folder

escopecz avatar Mar 15 '22 12:03 escopecz