强制FACEBOOK GRAPH API显示个人资料网址图片,而不是下载它 [英] Force FACEBOOK GRAPH API to show profile url image instead download it

查看:207
本文介绍了强制FACEBOOK GRAPH API显示个人资料网址图片,而不是下载它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Facebook API Graph 8.0,我得到了JSON

Working with Facebook API Graph 8.0, I get a JSON with

https://graph.facebook.com/v8.0/1234567890?fields=picture&redirect=false&access_token=my_secret_token

具有以下内容:

{
  "picture": {
    "data": {
      "height": 100,
      "is_silhouette": false,
      "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=1234&height=100&width=100&ext=1234&hash=abc",
      "width": 100
    }
  },
  "id": "1234567890"
}

但是当我尝试做一个

<img src="https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=1234&height=100&width=100&ext=1234&hash=abc">

不起作用,在浏览器中它下载并没有显示.

doesn't work, and in a browser it downloads it and not showing.

我如何使用图像和/或如何检索Facebook个人资料URL来显示它?

How can I use the image and/or how can i retrieve the Facebook Profile URL in order to show it?

预先感谢

推荐答案

如果您只想显示图像,则与使用访问令牌查询图形api然后显示图像相比,显示图像的方法要容易得多.

if you just want to show your image there is a much easier way to show images than querying graph api with access token and then showing the image.

您可以直接将其与<img>标签一起使用.

you can directly use it with <img> tag.

只需将/picture添加到api调用的结尾

just add /picture to the end of api call like this

<img src="https://graph.facebook.com/1234567890/picture">

您还可以请求不同的尺寸,例如

you can also request different sizes like

<img src="https://graph.facebook.com/1234567890/picture?width=360&height=900">

或带有方形缩略图

or a square thumbnail with

<img src="https://graph.facebook.com/1234567890/picture?type=square">

有关更多信息,请在此处检查: Facebook图形API v8用户图片 通知

for more informations check here : Facebook graph api v8 User Picture Notice

Facebook有两种UID,一种是每个用户加入facebook.com时分配的原始UID,另一种是每个用户在安装Facebook应用程序时获得的App-Scope UID.您的应用程序在调用诸如/me之类的终结点时将始终检索应用程序范围UID.获取原始UID的方法是通过使用不同的技术手动收集原始UID或将其设置为自动执行此Web爬虫程序.

Facebook has two kinds of UIDs one is the original UID each user is assigned when they join facebook.com and the other is App-Scope UID each user gets when they install a facebook app. your app would always retrive App-Scope UID when calling endpoints like /me. the way to get original UID is either by manually collecting them with different techniques or setting a web-scrapper to do so automatically.

facebook不赞成使用/user_id/picture终结点访问照片,除非提供了access_token,否则不应打扰任何人,因为所有应用程序都将获得应用程序范围UID,除非您尝试调试应用程序并且无法弄清楚为什么不这样做工作.

facebook is deprecating accessing photos with /user_id/picture endpoint when user_id is original UID unless access_token is provided this should not bother anyone because all apps get the app Scope UID unless you are trying to debug your app and cant figure out why it's not working.

这篇关于强制FACEBOOK GRAPH API显示个人资料网址图片,而不是下载它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆