通过 ID 获取用户个人资料图片 [英] Get user profile picture by Id

查看:37
本文介绍了通过 ID 获取用户个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在开发一个主要基于 Facebook 图形 API 的 Web 应用程序.我保存了一些关于用户的数据——实际上,可能是可用的公共数据——比如姓名和 ID.我也知道个人资料图片是公共数据的一部分,我想知道如何仅通过使用他的 id 就能够获得指向用户个人资料图片的直接链接?

I'm now working on a web application which is mostly based of facebook graph api. I hold some data about users - actually , the possible public data available - such as name and id. I also know that a profile picture is a part of the public data, and I wondered how I'll be able to get a direct link to a profile picture of a user only by using his id?

提前致谢

推荐答案

http://graph.facebook.com/" + facebookId + "/picture?type=square例如:http://graph.facebook.com/67563683055/picture?type=square

http://graph.facebook.com/" + facebookId + "/picture?type=square For instance: http://graph.facebook.com/67563683055/picture?type=square

除了square"之外,还有更多尺寸.请参阅文档.

There are also more sizes besides "square". See the docs.

2020 年 9 月更新
随着 Facebook 更新了他们的文档,这种方法在没有令牌的情况下不再有效.您需要附加某种access_token.您可以在 用户图片的图形api

需求变化此端点支持应用范围用户 ID (ASID)、用户 ID (UID) 和页面范围用户 ID (PSID).目前,您可以在没有要求的情况下查询 ASID 和 UID.但是,从 2020 年 10 月 24 日开始,所有基于 UID 的查询都将需要访问令牌.如果您查询一个 UID,因此必须包含一个令牌:

Requirements Change This endpoint supports App-Scoped User IDs (ASID), User IDs (UID), and Page-Scoped User IDs (PSID). Currently you can query ASIDs and UIDs with no requirements. However, beginning October 24, 2020, an access token will be required for all UID-based queries. If you query a UID and thus must include a token:

使用用户访问令牌进行 Facebook 登录身份验证请求
对页面范围的请求使用页面访问令牌
对服务器端请求使用应用访问令牌
将客户端访问令牌用于移动或 Web 客户端请求

use a User access token for Facebook Login authenticated requests
use a Page access token for page-scoped requests
use an App access token for server-side requests
use a Client access token for mobile or web client-side requests

引用 fb 文档

这篇关于通过 ID 获取用户个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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