如何使用 FB.api('/me/picture') 获取个人资料图片 [英] How to use FB.api('/me/picture') to get profile image

查看:29
本文介绍了如何使用 FB.api('/me/picture') 获取个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常愚蠢的问题.我是 facebook Javascript SDK 的初学者.所以我试图让用户的个人资料图片显示我用过这个代码

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" />';
});

效果很好,但我想了解如何使用 FB.api('/me/picture') 来显示图像.

which worked fine, but I'm trying to understand how to use FB.api('/me/picture') to show the image.

推荐答案

/me/picture(或 /{user id}/picture)返回 HTTP 301 重定向到图像位置,以便您可以将其直接嵌入到 <img src...

/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...

如果您想检索 URL 并自己使用它,您需要通过以下方式明确请求它作为一个字段:

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

 /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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆