我正在尝试使用以下代码更新 G Suite 用户的用户照片:
this->api_client = new Google_Client();
$this->api_client->setScopes([
Google_Service_Directory::ADMIN_DIRECTORY_USER,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP,
Google_Service_Directory::ADMIN_DIRECTORY_USER_ALIAS,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP_MEMBER,
Google_Service_Directory::ADMIN_DIRECTORY_ORGUNIT,
]);
$this->setAuthentication();
$this->service = new Google_Service_Directory($this->api_client);
$image_url = $agent->getProfilePic();
$image = file_get_contents($image_url);
$encoded = base64_encode($image);
//web-safe encoded
$web_safe = strtr($encoded, '+/', '-_');
$user = new Google_Service_Directory_User();
$user->setThumbnailPhotoUrl($image_url);
$this->service->users->update([user_email], $user);
我收到 200 响应,但是在管理控制台上检查时,没有任何改变,用户仍然没有个人资料图片。
我尝试发送不安全的图片,并尝试将“+/=”替换为“-_”。但没有任何效果
文档真的很差,所以我没有轨道