【问题标题】:Why are Google's API response objects' property keys random two-character strings?为什么 Google 的 API 响应对象的属性键是随机的两个字符串?
【发布时间】:2015-08-08 17:58:58
【问题描述】:

所以我刚开始在我正在开发的应用程序中使用 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) {}

【问题讨论】:

  • 您有什么具体要求?
  • 看起来您使用的是私有 API,而不是 documented public APIs 之一。
  • 我不明白您所说的私有 API 是什么意思... googleAuth.signIn() 是一个文档化的函数。你能澄清一下你的意思吗?

标签: javascript google-api google-plus


【解决方案1】:

Google 通过方便的 getter 方法公开这些属性。例如,要获取配置文件信息,您可以使用 gapi.oauth2.BasicProfile 对象的以下 getter:

// profile id
gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getId();
// profile name
gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getName();

【讨论】:

  • “方便”好吧,这当然是一种意见
  • 我注意到吸气剂实际上并不总是有效。痛苦。
猜你喜欢
  • 2020-09-05
  • 1970-01-01
  • 1970-01-01
  • 2012-11-26
  • 2012-11-30
  • 1970-01-01
  • 2020-12-25
  • 2023-04-07
相关资源
最近更新 更多