I am trying to set the default curl timeout in the scripts I am using for batch updating users using directory api. Only a handful of users are added before the curl connection times out.
I have tried this but it doesn't work with the API v2.2.2
Can someone show me how to update the curl timeout settings using php?
Thank you.
Here is the code:
$groupEmail = "my group email";
require_once realpath(dirname(__FILE__).'/vendor/autoload.php');
$client = new Google_Client();
$client->setAuthConfig('my-config.json');
$client->useApplicationDefaultCredentials();
$client->setScopes(array('https://www.googleapis.com/auth/admin.directory.user.readonly',
'https://www.googleapis.com/auth/admin.directory.group'));
$client->setSubject('user being impersonated');
$service = new Google_Service_Directory($client);
try {
//try something
for($i=1;$i<=1000;$i++)
{
$addThese[] = "something".$i."@gmail.com";
}
//EXECUTE ADDITIONS AND REMOVEALS
$client->setUseBatch(true);
$batch = new Google_Http_Batch($client);
foreach($addThese as $addThis)
{
$member = new Google_Service_Directory_Member(array('email' => $addThis,
'kind' => 'admin#directory#member',
'role' => 'MEMBER',
'type' => 'USER'));
$batch->add($service->members->insert($groupEmail, $member));
}
$result = $batch->execute();
} catch (Exception $e) {
// do something about the error
//echo "Error: $e";
}