所以我刚刚开始在我正在开发的应用程序中使用 Google 的 Gplus API,一切都工作正常,但我对 Google 的响应对象似乎具有完全随机的两个字符字符串作为其属性键这一事实感到非常困惑。例如,这是我得到的:
WE {El: "100327378902537923764", Ka: Object, wc: PG}
El: "100327378902537923764"
Ka: Object
wc: PG
Ka: "100327378902537923764"
Ld: "Thomas Moore"
wc: "example@gmail.com"
zt: "https://lh6.googleusercontent.com/-example/AAAAAAAAAAI/AAAAAAAAMPA/Vo75ASRTN_k/s96-c/photo.jpg"
我正在使用 JavaScript sdk 和 Angular。非常好奇是否有人对此有合理的解释
编辑:这是我提出的请求:
gapi.auth2.getAuthInstance().then(function (googleAuth) {
googleAuth.signIn({ 'scope': 'profile email' }).then(function (result) {}
最佳答案
Google 通过方便的 getter 方法公开这些属性。例如,要获取配置文件信息,您可以使用 gapi.oauth2.BasicProfile
对象的以下 getter:
// profile id
gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getId();
// profile name
gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getName();
关于javascript - 为什么 Google 的 API 响应对象的属性键是随机的两个字符的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31896929/