Facebook 有类似 Gravatar 的服务吗
如果 Gravatar 没有存档用户的图像,我想使用 facebook 上的图片。我可以通过 facebooks API 做到这一点吗?
I would like to use pictures from facebook if Gravatar does not have an image for the user on file. Can I do this through facebooks API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 users.getInfo API 方法。如果用户已安装您的应用程序,或通过 Facebook Connect 在您的网站上“连接”到 Facebook,则您可以访问包括其个人资料图片版本的个人资料信息。
如果您没有用户的会话密钥(即用户尚未安装您的应用程序或通过 Facebook Connect 连接),您仍然可以获得“方形”个人资料图片,这是较小的版本之一。您可以直接使用 API 进行查询。
总体而言,最简单的方法可能是使用 fb:profile-pic 标签和 XFBML。您必须安装 Facebook Connect 库才能执行此操作,但您不需要用户登录或执行任何操作即可让 XFBML 正常工作...只要页面上有 Javascript 库和 API密钥使用,它会起作用。
Take a look at the users.getInfo API method. If a user has installed your application, or "connected" to Facebook on your site through Facebook Connect, then you have access to profile information that includes versions of their profile picture.
If you don't have a session key for the user (ie, the user hasn't installed your app or connected via Facebook Connect), you can still get the "square" profile picture, which is one of the smaller versions. You can query for this directly using the API.
The easiest way overall is probably to use the fb:profile-pic tag and XFBML. You will have to install the Facebook Connect libraries to do this, but you don't need the user to log in or anything in order to get XFBML to work... as long as you have the Javascript library on the page and an API Key to use, it will work.