Mar*_*tin 84 facebook facebook-graph-api
我目前正在使用Graph API Explorer进行一些测试.这是一个很好的工具.
我想获取用户的朋友列表,包括朋友的姓名,ID和图片.所以我键入:
https://graph.facebook.com/me/friends?fields=id,picture,name
Run Code Online (Sandbox Code Playgroud)
但是图片只有50x50,我希望在这个请求中有一个更大的图片.
可能吗 ?
tha*_*smt 192
如Facebook上的此错误所述,您现在还可以通过新的API" 字段扩展 "语法请求特定的图像大小.
像这样:
https://graph.facebook.com/____OBJECT_ID____?fields=picture.type(large)
Run Code Online (Sandbox Code Playgroud)
lus*_*chn 76
让所有朋友(当然也正在使用App)的正确图片尺寸的最佳方法是使用字段扩展,使用其中一个尺寸标签(方形,小尺寸,普通尺寸,大尺寸):
/me/friends?fields=picture.type(large)
Run Code Online (Sandbox Code Playgroud)
(编辑:这不再起作用了)
...或者您可以指定宽度/高度:
me/friends?fields=picture.width(100).height(100)
Run Code Online (Sandbox Code Playgroud)
顺便说一下,你也可以这样写:
me?fields=friends{picture.type(large)}
Run Code Online (Sandbox Code Playgroud)
gul*_*yuz 66
你不需要拉"图片"属性.有更便捷的方式,你唯一需要的是userid,见下面的例子;
https://graph.facebook.com/user_id/picture?type=large
ps类型定义所需的大小
请注意,使用具有基本权限的令牌,/ me/friends将返回仅具有id + name属性的朋友列表
Jul*_*ann 33
将字段数组更改id,name,picture为id,name,picture.type(large)
https://graph.facebook.com/v2.8/me?fields=id,name,picture.type(large)&access_token=<the_token>
Run Code Online (Sandbox Code Playgroud)
结果:
{
"id": "130716224073524",
"name": "Julian Mann",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/15032818_133926070419206_3681208703790460208_n.jpg?oh=a288898d87420cdc7ed8db5602bbb520&oe=58CB5D16"
}
}
}
Run Code Online (Sandbox Code Playgroud)
Agu*_*ndo 28
您可以设置图片的大小(以像素为单位),如下所示:
https://graph.facebook.com/v2.8/me?fields=id,name,picture.width(500).height(500)
Run Code Online (Sandbox Code Playgroud)
以类似的方式,type可以使用参数
{user-id}/?fields=name,picture.type(large)
Run Code Online (Sandbox Code Playgroud)
从文档中
type enum {small,normal,album,large,square}
Jon*_*ark 20
我广泛研究了Graph API Explorer,最后找到了full_picture
https://graph.facebook.com/v2.2/$id/posts?fields=picture,full_picture
Run Code Online (Sandbox Code Playgroud)
PS我注意到full_picture不会总是提供我想要的全尺寸图像.'附件'确实如此
https://graph.facebook.com/v2.2/$id/posts?fields=picture,full_picture,attachments
Run Code Online (Sandbox Code Playgroud)
Swa*_*rks 19
您也可以根据高度或宽度尝试获取图像
https://graph.facebook.com/user_id/picture?height=
要么
https://graph.facebook.com/user_id/picture?width=
默认情况下,这些值只需要提供int值
嗯......我想我找到了解决方案.
事实上,在可以只是请求
https://graph.facebook.com/me/friends?fields=id,name
Run Code Online (Sandbox Code Playgroud)
根据http://developers.facebook.com/docs/reference/api/("图片"部分),可以使用用户ID构建个人资料照片的网址
例如,假设用户ID在$ id中:
"http://graph.facebook.com/$id/picture?type=square"
"http://graph.facebook.com/$id/picture?type=small"
"http://graph.facebook.com/$id/picture?type=normal"
"http://graph.facebook.com/$id/picture?type=large"
Run Code Online (Sandbox Code Playgroud)
但它不是最终的图像URL,所以如果有人有更好的解决方案,我会很高兴知道:)
您可以在 Facebook 图形 API 的请求中指定width& :heighthttp://graph.facebook.com/user_id/picture?width=500&height=500
| 归档时间: |
|
| 查看次数: |
98624 次 |
| 最近记录: |