2013-08-20 68 views
3

我使用PHP Google API Client Library從使用OAuth2的Google帳戶檢索用戶信息。然而,儘管Google's documentation states,我似乎無法訪問用戶的國家時區信息,即使令牌成功返回,並可以從userinfo.profile範圍獲得所有其他信息。如何從Google OAuth2獲取用戶國家和時區信息PHP客戶端

我使用的示例代碼提供INT繼承人庫here如果我var_dump($user)在該文件上我得到的線49以下的輸出(與新版本的隱私問題):

array(10) { 
    ["id"]=> 
    string(21) "123" /* Redacted */ 
    ["email"]=> 
    string(13) "[email protected]" /* Redacted */ 
    ["verified_email"]=> 
    bool(true) 
    ["name"]=> 
    string(14) "Sherif Ramadan" 
    ["given_name"]=> 
    string(6) "Sherif" 
    ["family_name"]=> 
    string(7) "Ramadan" 
    ["link"]=> 
    string(27) "https://plus.google.com/XXX" /* Redacted */ 
    ["picture"]=> 
    string(0) "https://lh3.googleusercontent.com/-XXX-Zs/AAAAAAAAAA/AAAAAAAAA/cmBwzMLdYqM/photo.jpg" /* Redacted */ 
    ["gender"]=> 
    string(4) "male" 
    ["locale"]=> 
    string(2) "en" 
} 

正如你所看到的沒有時區或國家信息可用。我也嘗試過各種示波器,例如https://www.googleapis.com/auth/plus.login,https://www.googleapis.com/auth/plus.me,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profilehttps://www.googleapis.com/auth/userinfo,但沒有運氣。他們似乎都提供了相同的結果。

我確保儘可能多的會話/緩存和其他方面不是一個因素。甚至更新auth tooken。什麼都沒有

任何人都有一些關於如何通過適用於PHP的Google API客戶端庫正確檢索這些信息的見解將是一個很大的幫助。

回答

1

事實證明,這些信息根本不是Google提供的,它們的文檔已經過時。

+0

同意。文檔如此分散,幾乎不可能找到您要查找的內容。更不用說這是多麼糟糕的文件。我怎麼能像谷歌一樣無法記錄他們的API?這隻會傷害他們,因爲開發人員不願意使用他們的API。 –