-1

I try to find all aliases from an user with the gmail API with PHP :

function recupererAlias($user)
{
   $gmail = objetGmailAPI($user);
    try
    {
       $req = $gmail->users_settings_sendAs->list($user);
       return $req;
    } catch (exception $e) {
        return 'Error<hr/>'.$e;
    }
}

The error is:

Call to undefined method Google_Service_Gmail_Resource_UsersSettingsSendAs::list(

Why?

El_Vanja
  • 3,660
  • 4
  • 18
  • 21
Aziros
  • 1
  • Well, clearly that class doesn't have that method, as the error suggests. When an error like that happens, you should do a search of the class name to try and find its [documentation](https://github.com/googleapis/google-api-php-client-services/blob/master/src/Google/Service/Gmail/Resource/UsersSettingsSendAs.php#L93) and locate the proper method in it. – El_Vanja May 06 '21 at 12:18
  • Thank you very much for the answer, I looked at the doc but not in the right place ;) – Aziros May 06 '21 at 13:16

1 Answers1

0

The correct syntax is :

function recupererAlias($user)
{
   $gmail = objetGmailAPI($user);
    try
    {
       $req = $gmail->users_settings_sendAs-> listUsersSettingsSendAs($user);
       return $req;
    } catch (exception $e) {
        return 'Error<hr/>'.$e;
    }
}

Thank you to El_Vanja for the help, I see the documentation like his advice. Thanks again :)

Aziros
  • 1