I am trying to create a group using google directory api.
But i am getting this error
Catchable fatal error: Argument 1 passed to Google_Service_Directory_Groups_Resource::insert() must be an instance of Google_Service_Directory_Group, array given, called in C:\xampp\htdocs\groups\index.php on line 94 and defined in C:\xampp\htdocs\groups\google-api-php-client\src\Google\Service\Directory.php on line 2196
I have used this code
<?php
include_once 'google-api-php-client/src/Google/autoload.php';
$clientId = 'jkdjdjkdjkdjk';
$serviceAccountName = 'gserviceaccount.com';
$delegatedAdmin = 'myemailid@gmail.com';
$keyFile = 'myfile.p12';
$appName = 'Example App';
$scopes = array(
'https://www.googleapis.com/auth/admin.directory.group'
);
$creds = new Google_Auth_AssertionCredentials(
$serviceAccountName,
$scopes,
file_get_contents($keyFile)
);
$creds->sub = $delegatedAdmin;
/**
* Create Google_Client for making API calls with
*/
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setClientId($clientId);
$client->setAssertionCredentials($creds);
$dir = new Google_Service_Directory($client);
$postBody = array('email'=>'sales_group@domain.com');
$list = $dir->groups->insert($postBody);
print_r($list);