title: Google Groups Directory API - Can't add new member
body: <p>I'm trying to integrate something into our website to add new members to our Google Groups mailing list when they create an account. I'm using the PHP API of the Admin SDK to do so, but have had no luck</p>
  
  <p>Here's the code</p>
  
  <pre><code>include_once 'autoload.php';
  $clientId = 'xxxxxxx.apps.googleusercontent.com';
  
  $serviceAccountName = 'xxxxxx@developer.gserviceaccount.com';
  
  $delegatedAdmin = 'admin@website.org';
  
  $keyFile = 'key.p12';
  
  $appName = 'App Name';
  
  $scopes = array(
      'https://www.googleapis.com/auth/admin.directory.group'
  );
  
  
  if (!($creds = new Google_Auth_AssertionCredentials(
      $serviceAccountName,
      $scopes,
      file_get_contents($keyFile)
  ))) {
      echo 'creds failed';
      exit;
  }
  
  if (!($creds-&gt;sub = $delegatedAdmin)) {
      echo 'sub failed';
      exit;
  }
  
  if (!($client = new Google_Client())) {
      echo 'obj creation failed failed';
      exit;
  }
  if (!($client-&gt;setApplicationName($appName))) {
      echo 'app name failed';
      exit;
  }
  if (!($client-&gt;setClientId($clientId))) {
      echo 'set id failed';
      exit;
  }
  if (!($client-&gt;setAssertionCredentials($creds))) {
      echo 'assertion failed';
      exit;
  }
  if (!($dir = new Google_Service_Directory($client))) {
      echo 'dir failed';
      exit;
  }
  
  if (!($member = new Google_Service_Directory_Member(array(
                          'email' =&gt;'validtestemail@test.test',
                          'kind' =&gt; 'admin#directory#member',
                          'role' =&gt; 'MEMBER',
                          'type' =&gt; 'USER')))) {
      echo 'member failed';
      exit;
  }
  
  if (!($list = $dir-&gt;members-&gt;insert('groupname@googlegroups.com', $member))) {
      echo 'list failed';
      exit;
  }
  echo 'good';
  </code></pre>
  
  <p>If I run it, the code stops at the set app name, or setting any properties of $client for that matter. If I comment those sections out, I get a blank page.</p>