如果使用与有效 Google 账号不对应的电子邮件地址调用 User::__construct(),则会创建对象,但该对象与实际的 Google 账号不对应。即使有人在存储了该对象后用指定的电子邮件地址创建了 Google 账号,也将出现这种情况。如果创建 User 值时使用的电子邮件地址当时不代表 Google 账号,则该 User 值将永远不会匹配代表真正用户的 User 值。
有效用户的 User 对象可以为该用户提供唯一的 ID 值,即使该用户更改了其电子邮件地址,该 ID 值也保持不变。getUserId() 方法会返回此 ID,这是一个 string 值。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[[["The `User` class represents a unique user, and two equal instances signify the same user."],["`UserService::getCurrentUser()` retrieves the `User` instance for the current user, regardless of the authentication method."],["A `User` instance can be created from an email address, but it may not correspond to a valid Google account."],["The `getUserId()` method of a `User` object provides a unique ID that remains consistent even if the user's email changes."],["This API is only for first-generation runtimes, and a migration guide is available for updates to PHP 7/8 runtimes."]]],[]]