ID로 사용자 프로필 사진 가져 오기
나는 지금 주로 페이스 북 그래프 API를 기반으로하는 웹 응용 프로그램을 만들고 있습니다. 사용자에 관한 데이터 (실제로 사용 가능한 공개 데이터 (예 : 이름 및 ID))를 보유하고 있습니다. 또한 프로필 사진이 공개 데이터의 일부라는 것을 알고 있으며 자신의 ID 만 사용하여 사용자의 프로필 사진으로 직접 링크를 얻는 방법이 궁금했습니다.
미리 감사드립니다
http://graph.facebook.com/ "+ facebookId +"/ picture? type = square 예 : http://graph.facebook.com/67563683055/picture?type=square
"사각형"외에 다른 크기도 있습니다. 문서를 참조하십시오 .
다음 URL을 사용하여 다양한 크기의 프로필 이미지를 얻을 수 있습니다. URL에 Facebook ID를 추가하십시오.
대형 사진 https://graph.facebook.com/ {facebookId} / picture? type = large
중간 크기의 사진 https://graph.facebook.com/ {facebookId} / picture? type = normal
소형 사진 https://graph.facebook.com/ {facebookId} / picture? type = small
정사각형 사진 https://graph.facebook.com/ {facebookId} / picture? type = square
이미지의 가장 큰 크기를 얻으려면
https://graph.facebook.com/{userID}?fields=picture.width(720).height(720)
또는 크기로 필요한 다른 것. 경험을 바탕으로 type = large는 얻을 수있는 가장 큰 결과가 아닙니다.
이 링크가 도움이 될 것입니다 :
http://graph.facebook.com/893914824028397/picture?type=large&redirect=true&width=500&height=500
필요에 따라 높이와 너비를 설정할 수 있습니다
893914824028397 은 facebookid입니다
이것은 문자 그대로 Graph API 문서 의 첫 페이지에 있습니다 .
/OBJECT_ID/picture
객체의 사진 (이 경우 사용자)으로 리디렉션을 반환합니다./OBJECT_ID/?fields=picture
사진의 URL을 반환
예 :
<img src="https://graph.facebook.com/4/picture"/>
Zuck의 프로필 사진으로 HTTP 301 리디렉션을 사용합니다.
https://graph.facebook.com/4?fields=picture
URL 자체를 돌려줍니다
여기,이 API를 사용하면 FB, Google 및 Twitter 프로필 사진을 쉽게 얻을 수 있습니다
Twitter, Facebook, Instagram 및 gravatar를 포함한 다양한 소셜 네트워크에 대한 사용자 이름이 주어지면 프로필 이미지를 반환하는 API입니다. iOS, Android, Ruby, Node, PHP, Python 및 JavaScript 용 라이브러리가 있습니다.
img 태그의 src에서 url as : https : //graph.facebook.com/ user_id / picture? type = square를 사용하십시오. 유형이 작을 수 있습니다 .
이를 위해 AngularJ를 사용할 수 있습니다. 양방향 데이터 바인딩 기능은 최소한의 노력과 적은 코드로 솔루션을 제공합니다.
<div> <input type="text" name="" ng-model="fbid"><br/> <img src="https://graph.facebook.com/{{fbid}}/picture?type=normal"> </div>
이 질문에 대한 답변이 되었기를 바랍니다. 참고 : 다른 라이브러리도 사용할 수 있습니다.
이 URL을 사용하여 얻을 수 있습니다 : 그림 HD (최대 크기)를 얻습니다.
https://graph.facebook.com/{userID}?fields=picture.width(720).height(720)&redirect=false
redirect = false를 잊지 마십시오. 그렇지 않으면 오류가 반환됩니다
관통 자바 스크립트 SDK (v2.12 - 4 월 2017) 당신은 사진 요청이 방법의 세부 사항을 얻을 수 있습니다 :
FB.api("/" + uid + "/picture?redirect=0", function (response) {
console.log(response);
// prints the following:
//data: {
// height: 50
// is_silhouette: false
// url: "https://lookaside.facebook.com/platform/profilepic/?asid=…&height=50&width=50&ext=…&hash…"
// width: 50
//}
if (response && !response.error) {
// change the src attribute of img elements
[...document.getElementsByClassName('fb-user-img')].forEach(
i => i.src = response.data.url
);
// OR redirect to the URL above
location.assign(response.data.url);
}
});
JSON 응답을 매개 변수를 얻기 위해 redirect
와 0 값으로 (영) 기본적으로 이미지에 대한 요청 리디렉션 이후 중요하다. 동일한 URL에 다른 매개 변수를 계속 추가 할 수 있습니다. 예 :
"/" + uid + "/picture?redirect=0&width=100&height=100"
: 100x100 이미지가 반환됩니다."/" + uid + "/picture?redirect=0&type=large"
: a 200x200 image is returned. Other possible type values include: small, normal, album, and square.
Simply Follow as below URL
https://graph.facebook.com/facebook_user_id/picture?type=square
type may be normal,small,medium,large. Or square (f you want to get square picture, the square size is limited to 50x50).
As per the current latest Facebook API version 3.2, For users you can use this generic method for getting profile picture is https://graph.facebook.com/v3.2/{user-id}/picture?type=square you can visit documentation for user picture here. The possible values for type parameter in URL can be small, normal, album, large, square
For Groups and Pages, the profile picture is not available directly. You have to get them using access token. For Groups you have to use User Access Token and for Pages you can use both User Access Token and Page Access Token.
You can get Group's or Page's Profile Picture using the generic URL: https://graph.facebook.com/v3.2/{user-id}/picture?access_token={access-token}&type=square
I hope this is helpful for people who are looking for Page or Group Profile picture.
참고URL : https://stackoverflow.com/questions/11442442/get-user-profile-picture-by-id
'Programing' 카테고리의 다른 글
FragmentPagerAdapter getItem이 호출되지 않았습니다 (0) | 2020.07.20 |
---|---|
에뮬레이터에서 AVD를 시작할 수 없음 : QT 라이브러리를 찾을 수 없음 (0) | 2020.07.20 |
UIButton의 titleLabel에 대해 x, y 위치를 조정할 수 있습니까? (0) | 2020.07.20 |
Android Studio 및 Gradle과 함께 ViewPagerIndicator 라이브러리 사용 (0) | 2020.07.20 |
숫자에 st, nd, rd 및 th (소수) 접미사 추가 (0) | 2020.07.20 |