【问题标题】:Get updated URL to facebook user's profile pic获取 facebook 用户个人资料图片的更新 URL
【发布时间】:2021-04-02 13:17:01
【问题描述】:

我正在使用 facebook 的图形 API 来获取有关用户的基本信息。 在向/me?fields=id,name,picture 发送请求时,我收到以下响应

{
  "id": "645636655991071",
  "name": "Rahul Dahal",
  "picture": {
    "data": {
      "height": 50,
      "is_silhouette": false,
      "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=645636655991071&height=50&width=50&ext=1619960875&hash=AeSav5aZhqO_ExOLOPc",
      "width": 50
    }
  }
}

picture 对象的url 属性有图片的 URL,但在一定时间后过期。

这意味着我无法将该 URL 存储在数据库中。

如何获取图片的更新 URL?

【问题讨论】:

标签: javascript html facebook-graph-api fetch


【解决方案1】:

试试这个代码 sn-p:

.fit-picture {
    width: 50px;
}
<img class="fit-picture"
     src="https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=645636655991071&height=50&width=50&ext=1619960875&hash=AeSav5aZhqO_ExOLOPc"
     alt="Grapefruit slice atop a pile of other slices">

【讨论】:

  • 它确实有效。但是,我了解到该网址将在一定时间后过期。你知道如何获取更新的网址吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-11-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-20
相关资源
最近更新 更多