Facebook Graph API : 한 번의 요청으로 더 큰 사진 가져 오기
현재 Graph API Explorer 를 사용하여 몇 가지 테스트를하고 있습니다. 그것은 좋은 도구입니다.
친구의 이름, 아이디, 사진과 함께 사용자의 친구 목록을 얻고 싶습니다. 그래서 다음을 입력합니다.
https://graph.facebook.com/me/friends?fields=id,picture,name
하지만 사진은 50x50에 불과하며이 요청에서 더 큰 사진을 원합니다.
가능합니까?
그래도 '그림'속성을 가져올 필요는 없습니다. 훨씬 더 편리한 방법이 있습니다. 필요한 것은 userid뿐입니다. 아래 예를 참조하세요.
https://graph.facebook.com/user_id/picture?type=large
ps 유형은 원하는 크기를 정의합니다.
plz는 기본 권한이있는 토큰을 사용하면 / me / friends는 id + name 속성이있는 친구 목록 만 반환합니다.
Facebook 의이 버그 에 설명 된대로 이제 새 API " field expansion "구문을 통해 특정 이미지 크기를 요청할 수도 있습니다 .
이렇게 :
https://graph.facebook.com/____OBJECT_ID____?fields=picture.type(large)
모든 친구 (물론 앱을 사용하는)를 올바른 사진 크기로 얻는 가장 좋은 방법 은 크기 태그 (정사각형, 소형, 보통, 대형) 중 하나 를 사용하여 필드 확장 을 사용 하는 것입니다.
/me/friends?fields=picture.type(large)
(편집 : 더 이상 작동하지 않음)
... 또는 너비 / 높이를 지정할 수 있습니다.
me/friends?fields=picture.width(100).height(100)
Btw, 다음과 같이 작성할 수도 있습니다.
me?fields=friends{picture.type(large)}
필드의 배열을 변경 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>
결과:
{
"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"
}
}
}
다음과 같이 그림의 크기를 픽셀 단위로 설정할 수 있습니다.
https://graph.facebook.com/v2.8/me?fields=id,name,picture.width(500).height(500)
유사한 방식으로 type
매개 변수를 사용할 수 있습니다.
{user-id}/?fields=name,picture.type(large)
로부터 문서
enum {small, normal, album, large, square} 유형
Graph API Explorer를 광범위하게 조사하고 마침내 full_picture를 찾았습니다.
https://graph.facebook.com/v2.2/$id/posts?fields=picture,full_picture
추신 : full_picture가 내가 원하는 전체 크기 이미지를 항상 제공하지는 않는다는 것을 알았습니다. '첨부 파일'은
https://graph.facebook.com/v2.2/$id/posts?fields=picture,full_picture,attachments
높이나 너비를 기준으로 원하는 경우 이미지를 가져올 수도 있습니다.
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
http://developers.facebook.com/docs/reference/api/("Pictures "섹션) 에 따르면 사용자 ID로 프로필 사진의 URL을 만들 수 있습니다.
예를 들어 사용자 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"
그러나 최종 이미지 URL이 아니므로 누군가가 더 나은 솔루션을 가지고 있다면 기뻐할 것입니다. :)
From v2.7
, /<picture-id>?fields=images
will give you a list with different size of the images, the first element being the full size image.
I don't know of any solution for multiple images at once.
You can specify width & heigth in your request to Facebook graph api: http://graph.facebook.com/user_id/picture?width=500&heigth=500
In pictures URL found in the Graph responses (the "http://photos-c.ak.fbcdn.net/" ones), just replace the default "_s.jpg" by "_n.jpg" (? normal size) or "_b.jpg" (? big size) or "_t.jpg" (thumbnail).
Hacakable URLs/REST API make the Web better.
rest-fb users (square image, bigger res.): Connection myFriends = fbClient.fetchConnection("me/friends", User.class, Parameter.with("fields", "public_profile,email,first_name,last_name,gender,picture.width(100).height(100)"));
I think that as of now the only way to get large pictures of friends is to use FQL. First, you need to fetch a list of friends:
https://graph.facebook.com/me/friends
Then parse this list and extract all friends ids
. When you have that, just execute the following FQL query:
SELECT id, url FROM profile_pic WHERE id IN (id1, id2) AND width=200 AND height=200
200
here is just an exemplary size, you can enter anything. You should get the following response:
{
"data": [
{
"id": ...,
"url": "https://fbcdn-profile-a.akamaihd.net/..."
},
{
"id": ...,
"url": "https://fbcdn-profile-a.akamaihd.net/..."
}
]
}
With each url being the link to a 200x200px image.
I have the same problem but i tried this one to solve my problem. it returns large image. It is not the perfect fix but you can try this one.
https://graph.facebook.com/v2.0/OBJECT_ID/picture?access_token=XXXXX
try to change the size of the image by changing the pixel size from the url in each json object as follows :
for example I change s480x480 to be s720x720
JS styled variant. Just set enormous large picture width and you will get the largest variant.
FB.api(
'/' + userId,
{fields: 'picture.width(2048)'},
function (response) {
if (response && !response.error) {
console.log(response.picture.data.url);
}
}
);
You can use full_picture instead of picture key to get full size image.
I got this error when I made a request with picture.type(full_picture)
:
"(#100) For field 'picture': type must be one of the following values: small, normal, album, large, square"
When I make the request with picture.type(album)
and picture.type(square)
, responses me with an image 50x50 pixel size.
When I make the request with picture.type(large)
, responses me with an image 200x200 pixel size.
When I make the request with picture.width(800)
, responses me with an image 477x477 pixel size.
with picture.width(250)
, responses 320x320.
with picture.width(50)
, responses 50x50.
with picture.width(100)
, responses 100x100.
with picture.width(150)
, responses 160x160.
I think that facebook gives the images which resized variously when the user first add that photo.
What I see here the API for requesting user Image does not support resizing the image requested. It gives the nearest size of image, I think.
참고URL : https://stackoverflow.com/questions/10650730/facebook-graph-api-get-larger-pictures-in-one-request
'Programing' 카테고리의 다른 글
xcrun : 오류 : 활성 개발자 경로 ( "/Applications/Xcode.app/Contents/Developer")가 없습니다. (0) | 2020.09.20 |
---|---|
앱 스토어의 애플리케이션에 유효한 'aps-environment'자격 문자열이 없습니다. (0) | 2020.09.20 |
UIView에서 선 그리기 (0) | 2020.09.20 |
신호 'SIGILL'의 원인은 무엇입니까? (0) | 2020.09.20 |
시퀀스 된 상태 전환 스트림으로 작성된 프로그램을 scalaz-stream으로 어떻게 대체합니까? (0) | 2020.09.20 |