需要使用Google PHP API库更新用户的帮助吗

需要使用Google PHP API库更新用户的帮助吗,php,google-api-php-client,Php,Google Api Php Client,我正在尝试使用最新的GooglePHPAPI库来更新用户,但我找不到任何关于如何使用它来更新的示例 我能找到的最接近的例子是这个,但它没有足够的信息来添加 下面是我所拥有的,它是从另一份从用户列表中提取的工作复制而来的。但其范围仅限于“ 不会更新任何东西 我搜索了又搜索,似乎找不到PHP更新用户的例子 session_start(); require 'vendor/autoload.php'; $SCOPE = 'https://www.googleapis.com/auth/admin.di

我正在尝试使用最新的GooglePHPAPI库来更新用户,但我找不到任何关于如何使用它来更新的示例

我能找到的最接近的例子是这个,但它没有足够的信息来添加

下面是我所拥有的,它是从另一份从用户列表中提取的工作复制而来的。但其范围仅限于“

不会更新任何东西

我搜索了又搜索,似乎找不到PHP更新用户的例子

session_start();
require 'vendor/autoload.php';
$SCOPE = 'https://www.googleapis.com/auth/admin.directory.user';

$SERVICE_ACCOUNT_EMAIL = 'BLAHBLAH@developer.gserviceaccount.com';
$SERVICE_ACCOUNT_PKCS12_FILE_PATH = 'blahblah.p12';

$client = new Google_Client();
$client->setApplicationName('BLahBlah.apps.googleusercontent.com');
$adminService = new Google_Service_Directory($client);
$key = file_get_contents($SERVICE_ACCOUNT_PKCS12_FILE_PATH);


$cred = new Google_Auth_AssertionCredentials($SERVICE_ACCOUNT_EMAIL, array($SCOPE), $key);
$cred->sub = "chriswhittle@lahlah.com";

$client->setAssertionCredentials($cred);

$email = "fred@tom.com";
$requestUrl = "https://www.googleapis.com/admin/directory/v1/users/" . urlencode($email) ;
$requestMethod = 'PUT';
$data = array("title" => "Cool Guy");
$requestHeader = array('Content-Type' => 'application/json', 'Content-Length' => 'CONTENT_LENGTH');

$request = new Google_Http_Request($requestUrl, $requestMethod,$requestHeader,$data);

$httpRequest = $client->getAuth()->authenticatedRequest($request);

代码很好,我必须进入我们的谷歌应用程序域安全设置,并授予用户编辑权限。并调整主体数据以匹配json。。。这里有一个例子

$data = array("organizations" => array(array("name"=>"My Company","title"=>"Director, Information Technology","primary"=>true,"customType"=>"Other","department"=>"Information Technology")),"name"=>array("familyName"=> "Admin"));