如何使用选择 View 用户集获取 facebook 照片(如果他们使用大图像)。如果我在路径图中使用 type = "large"or "normal"or "small"然后我得到图像但它不是正方形并且它不是用户集的选择 View 。那么,我怎样才能得到方形类型的照片及其用户集的 View
最佳答案
通过请求 width
的图片,您可以获得比 type=square
的普通图片更高尺寸的方形图片(尺寸仅为 50x50 像素)和 height
参数设置。
参见 https://developers.facebook.com/docs/reference/api/user/ ,“图片”连接,引用:
“Additionally, you can specify width and height URL parameters to request a picture of a specific size. This will return an available profile picture closest to the requested size and requested aspect ratio. […] if width=height, we will always return a square picture.”
例子:
https://graph.facebook.com/4/picture?type=square – 扎克伯格先生的“正常”方形头像,尺寸 50x50
https://graph.facebook.com/4/picture?width=100&height=100 – 100x100 像素,完美匹配要求的尺寸
https://graph.facebook.com/4/picture?width=150&height=150 – 要求 150x150,却得到 156x156。
如果您可以忍受有时获得的图像可能比请求的尺寸大(或小)一点,那么您应该没问题。
否则,它会进行一些测试,以确定是否有某些方形图片尺寸 Facebook 将始终“有货”并提供完全匹配的图片,或者是否可能因每个用户的图片而异已上传。
关于facebook - Graph API 获取照片正方形 (100x100),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11900780/