如果您是使用未對應至有效 Google 帳戶的電子郵件地址來呼叫 User::__construct(),儘管系統還是會建立物件,但該物件無法對應至確切的 Google 帳戶。即使在物件儲存後,使用者以指定的電子郵件地址建立了 Google 帳戶,這個物件依舊無法對應實際帳戶。建立 User 值時,如果這個值的電子郵件地址不代表「Google 帳戶」,則該值將永遠無法與代表實際使用者的 User 值配對。
有效使用者的 User 物件可以為使用者提供專屬的識別碼值,即便使用者變更電子郵件地址,識別碼仍會維持不變。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"]],["上次更新時間:2025-06-16 (世界標準時間)。"],[[["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."]]],[]]