如何使用FB.api('/ me / picture')获取配置文件图像 [英] How to use FB.api('/me/picture') to get profile image
问题描述
所以我试图使一个用户的个人资料图像显示
我使用这个代码
FB.api('/ me',function(response){
document.getElementById('login')。style.display =block;
document.getElementById('login')innerHTML = '< img src =http://graph.facebook.com/'+ response.id +'/ picture/>';
});
哪些工作正常,但我正在努力了解如何使用 FB .api('/ me / picture')
显示图像。
/ me / picture
(或 / {user id} / picture
)返回HTTP 301重定向到图像位置,以便您可以将其直接嵌入到< img src ...
如果您想要检索URL并自行使用,您需要通过以下方式专门请求该字段:
/ {user id}?fields = picture
或
/ me /?fields = picture
您也可以包含其他字段,但我假设您只是想要照片。
This is a very silly question. I'm a beginner with facebook Javascript SDK. So I'm trying to make a the user's profile image to show I used this code
FB.api('/me', function(response) {
document.getElementById('login').style.display = "block";
document.getElementById('login').innerHTML = '<img src="http://graph.facebook.com/' + response.id + '/picture" />';
});
which worked fine, but I'm trying to understand how to use FB.api('/me/picture')
to show the image.
/me/picture
(or /{user id}/picture
) returns an HTTP 301 redirect to the image location so you can embed it directly into an <img src...
If you want to retrieve the URL and use it yourself you need to specifically request it as a field, via :
/{user id}?fields=picture
or
/me/?fields=picture
You can include other fields too, but I'm assuming you just want the photo right now.
这篇关于如何使用FB.api('/ me / picture')获取配置文件图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!